BAT:if语句根据文件的修改日期 [英] BAT: if statement based on modify date of file

查看:480
本文介绍了BAT:if语句根据文件的修改日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想看看是否锁定文件修改日期比增加5秒前或者在将来(指示PC时钟被改回)。

I want to see if a lock file modify date is more than a 5 seconds ago or it in the future (indicating the PC clock was changed back).

我怎么能说


  • 如果file.modifydate<现在 - 5秒modifydate>现在结果

    • 运行命令(指挥将推出我的Java应用程序)


    • 运行命令B(b指令将一个UDP数据包发送到本地主机端口)

    推荐答案

    由于Wimmel的建议,我将使用VBScript - 好吧其实我会以同样的方式VBScript中通常会使用被使用JScript ......因为我已经熟悉JavaScript。

    As Wimmel suggested, I will be using VBScript - well actually I will be using JScript in the same way VBScript would normally be used... because I am already familiar with JavaScript.

    我张贴了这个问题:<一href=\"http://stackoverflow.com/questions/6348845/windows-xp-and-up-javascript-instead-of-vbscript\">Windows XP和向上:JavaScript的,而不是VBScript中

    其中有我将使用code

    Which has the code I will be using

    检查修改日期/时间

    var o = new ActiveXObject("Scripting.FileSystemObject");
    var file = o.GetFile("c:\\temp\\test.js");
    // WScript.Echo(file.DateLastModified); // This is the modify date/time with seconds
    

    和code给exec我的Java程序

    and code to exec my Java process

    WshShell = WScript.CreateObject("WScript.Shell");
    var result = WshShell.Run("command-goes-here", 0, true);
    // WSH.Echo(result); // this is the exit code
    

    命令B将被使用的建议,一个来自发送UDP数据包的Windows BAT或CMD:一些数据发送到本地主机的UDP端口

    的命令很可能是相同的,如果我使用的VBScript / JScript中所以他们应该可以正常工作。

    The commands would probably be the same if I used VBScript/JScript so they should work fine.

    唯一缺少的是:<一href=\"http://stackoverflow.com/questions/6348907/vbscript-jscript-networking-connect-either-udp-or-tcp\">VBScript/JScript网络:连接UDP或TCP

    如果我可以使用本机的功能,那肯定比命令B的EXEC更好。

    If I could use a native function, it would definitely be better than an exec of command b.

    这篇关于BAT:if语句根据文件的修改日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆