fsoehnge
asked on
How do I run a command after the server reboots
I am needing to run a command automatically after a Windows 2003 server reboots. The reboot is being decided from within a batch file. I have tried adding the following line to my controlling script prior to the reboot.
soon 300 "cmd /c mycommand"
This goes into the AT commandline scheduler quite nicely. Unfortunately, after rebooting the server, the AT scheduler is empty. Any way to keep this from happening, or any ideas on another to automatically run my command upon completion of the reboot?
soon 300 "cmd /c mycommand"
This goes into the AT commandline scheduler quite nicely. Unfortunately, after rebooting the server, the AT scheduler is empty. Any way to keep this from happening, or any ideas on another to automatically run my command upon completion of the reboot?
Running scripts after startup usually requires putting the script into the Documents and Settings\All Users\Start Menu\Startup folder or adding the script to the Run section in the registry. http://www.windowsnetworking.com/kbase/WindowsTips/WindowsXP/AdminTips/Miscellaneous/WindowsProgramStartupLocations.html has info on that.
ASKER
Any idea on why the AT schedule is getting cleared?
Havd you tried using scheduled tasks instead of the at scheduler?
ASKER
I have not figured a way to use now + 5 minutes with the scheduled tasks. with the at command I am able to use soon 300 to schedule a task for 5 minutes from now. do you know how I can use scheduler from the command line to do the same thing?
Why not put the command you need to run in a batch file and set the task.to.run on reboot. The batch file can then contain "soon" and effectively delay starting yhe program for 5 minutes.
ASKER
So, if I have
c:\scripts\mycommand.bat
how do I set that task to run on reboot?
c:\scripts\mycommand.bat
how do I set that task to run on reboot?
Go to Task Scheduler in the Administrative tools and create a new task. The "trigger" option includes settings for:
The one I think you want is in bold.
Daily
Weekly
Monthly
One time
When the computer starts
When I log on
When a specific event is logged
The one I think you want is in bold.
ASKER
I need to be able to do it from the command line.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.