Solved

How do I run a command after the server reboots

Posted on 2012-03-19
9
308 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 39

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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
 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn about cloud computing and its benefits for small business owners.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

809 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