Batch file if time


















Improve this answer. Greg Askew Greg Askew That's done it, cheers! Are you able to quickly outline why mine didn't work? Don't worry if it'd take a while to explain. EOF is end of file. Also the IF logic was a bit unclear, so it is easier to understand if you separate the tests for the time. Sign up or log in Sign up using Google. Sign up using Facebook.

Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. This would certainly not be my preference. Your Batch file would essentially be a loop, looking if the date required has been achieved.

If the value comparison if true, it would execute possibly a sub: and then return to the start of the loop. Here are 2 solutions: 1. The second line formats datetime in the form I needed for what I used it for. You can modify this line to format however suits your needs. Great information here. I am in need of a way to get the full 24 hr time displayed live. I am looking for a way to make that happen automatically without me hitting enter constantly.

Thanks in advance! Thank you very much Srini for this tutorial. I created my own Windows 10 Defender Virus scan batch command and used schedule task to run it and used your commands to create log files with date and time stamp.

Dear Sir I have an idea, Can you get the date and time string when you click and drag the bottom right clock of the windows taskbar, drag it to any filename box? How would I get the date into a variable for an actual, valuable use? Remove the slashes in the date. Remove the leading space from the time. Add a comment. Active Oldest Votes. Improve this answer. I tried your edited version, but it fail "randomly" depending on certain times. There were at least to possible problems in the posted code.

Now corrected. But yea, it might not work, so just check it before you put it up on your server. Monacraft Monacraft 6, 2 2 gold badges 14 14 silver badges 27 27 bronze badges. Well now that I made it you can just CP this and try it out. I just want to make sure one command happens exactly between those times and the other command exactly outside of that time period. I edited the question with what I came up with but I don't think it's the best way.

Thomas Fritsch 8, 33 33 gold badges 34 34 silver badges 46 46 bronze badges. It would be great to add some explanation how your code works. Sign up or log in Sign up using Google. Sign up using Facebook.



0コメント

  • 1000 / 1000