Solved

How do I run a command after the server reboots

Posted on 2012-03-19
9
306 Views
Last Modified: 2012-03-21
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?
0
Comment
Question by:fsoehnge
  • 4
  • 4
9 Comments
 
LVL 38

Expert Comment

by:Adam Brown
ID: 37739139
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
 

Author Comment

by:fsoehnge
ID: 37739149
Any idea on why the AT schedule is getting cleared?
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 37739157
Havd you tried using scheduled tasks instead of the at scheduler?
0
 

Author Comment

by:fsoehnge
ID: 37739167
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
Integrate social media with email signatures

Is your company active on social media? Do you also use email signatures? Including social media icons in your email signature is a great way to get fans for free. Let all your email users know you’re on social media quickly and easily, in a single click.

 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 37739363
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
 

Author Comment

by:fsoehnge
ID: 37739372
So, if I have
c:\scripts\mycommand.bat

how do I set that task to run on reboot?
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 37740197
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
 

Author Comment

by:fsoehnge
ID: 37744350
I need to be able to do it from the command line.
0
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 37745452
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip is around source server preparation. No migration is an easy migration, there is a…
Welcome to my series of short tips on migrations. Whilst based on Microsoft migrations the same principles can be applied to any type of migration. My first tip Migration Tip #1 – Source Server Health can be found here: http://www.experts-exchang…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now