Using WinBatch can you call a PowerShell script (.ps1 extention) every 12 hours? Example: I need to run a PowerShell script at 8:00am and 8:00pm 7 days per week. Using TimeDelay() won't work for this. So how do you script that?
Any reason you wouldn't want to just use Windows Task Scheduler?
Jim
Yes I did look at task schedule. What I am calling has to run interactive. So it has to run when a user is Logged into the system. Windows 7 and the newest GPO don't allow you to enter a password anymore. And if you choose "run whether user is logged on or not" it will not run interactive. So I want something running in the users context that will in turn kick off our reboot utility ever 12 hours. And the reboot utility checks the uptime of the system. If it has been up for more than 7 days it will throw up an interactive dialog that gives the user some options.
Will TimeWait() do what you need?
Jim
I found that and it should, but it would be crude. Example: I have to run it like this:
a=TimeYmdHms( ) ; Gets Current Time
b=TimeAdd(a,"0000:00:00:12:00:00")
TimeWait(b)
Run("\\mgserver\scripts\Tools\RebootTool\Reboot.exe", "")
TimeDelay()
and repeat this code for 7 days worth of running. I wanted to put the TimeWait() in some type of loop.
Why not something like:
stime = StrSub(TimeYmdHms(),1,10):":08:00:00"
While 1
TimeWait(stime)
Run("\\mgserver\scripts\Tools\RebootTool\Reboot.exe", "")
stime = TimeAdd(stime,"0000:00:00:12:00:00")
EndWhile
thanks that look clean. I will test it out.
With that option, you can have the login script start it.