Link to home
Start Free TrialLog in
Avatar of GTsafas
GTsafas

asked on

Batch scripting IF TIME = THIS OR LATER DO THIS

I need an if statement that says if the time is 6:45pm or later it creates a blank text document
ASKER CERTIFIED SOLUTION
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steve Knight
If you want to make sure it works despite any 12/24 hour tim formats you could use VBScript (I had also typed out an example such as above and a 12 hour version but then IE crashed :-(

if time > timeserial(13,45,00) then
  wscript.echo "Is after 6:45pm, creating file"
  Set objFSO = CreateObject("Scripting.FileSystemObject")
  Dim fileOutput: Set fileOutput = objFSO.CreateTextFile("C:\Output.txt")
  fileOutput.Close
  Set objFSO = Nothing
else
 wscript.echo "It is before 6:45pm"
end if
You can run that from a batch file as:

cscript //nologo checklate.vbs

Steve