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?
fsoehngeAsked:
Who is Participating?
 
Lee W, MVPConnect With a Mentor Technology and Business Process AdvisorCommented:
0
 
Adam BrownSr Solutions ArchitectCommented:
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.
0
 
fsoehngeAuthor Commented:
Any idea on why the AT schedule is getting cleared?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Havd you tried using scheduled tasks instead of the at scheduler?
0
 
fsoehngeAuthor Commented:
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?
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
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.
0
 
fsoehngeAuthor Commented:
So, if I have
c:\scripts\mycommand.bat

how do I set that task to run on reboot?
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Go to Task Scheduler in the Administrative tools and create a new task.  The "trigger" option includes settings for:
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.
0
 
fsoehngeAuthor Commented:
I need to be able to do it from the command line.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.