Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do I run a command after the server reboots

Posted on 2012-03-19
9
309 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
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