Execute a command at server reboot

  • Thread starter Thread starter BobW
  • Start date Start date
B

BobW

I need to run a simple command whenever a server is rebooted. I don't want
it to run when someone logs in, nor do I want it to require someone to log
in for it to run. Basically I need to run the command "TYPE MYFILE >
MYFILE" which creates a zero byte file that I then use as a "flag" that the
server has been rebooted. After I've done what I need to, this flag is then
deleted until the next time the server gets rebooted.

Obviously, since this is on a server, security is a concern. Don't want
someone "unauthorized" to be able to get to my command and change it.

Thanks in advance.
 
BobW said:
I need to run a simple command whenever a server is rebooted. I don't want
it to run when someone logs in, nor do I want it to require someone to log
in for it to run. Basically I need to run the command "TYPE MYFILE >
MYFILE" which creates a zero byte file that I then use as a "flag" that the
server has been rebooted. After I've done what I need to, this flag is then
deleted until the next time the server gets rebooted.

Obviously, since this is on a server, security is a concern. Don't want
someone "unauthorized" to be able to get to my command and change it.

Thanks in advance.

- To run a command at boot time: Use the Task Scheduler. It has an option
for just this.
- To create a 0-byte file: cd 2>c:\reboot.txt.
- To record when the machine was rebooted: echo %date% %time% %ComputerName%
rebooted > c:\reboot.txt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top