Jump to content

running script over reboot


Recommended Posts

Posted

I'd like to write a script file that executes a few commands then re-boots the host machine (Windows 7), and then starts over after it booted up, and do this X times. (X could be anything from 5 to 5,000)

I believe to do this I would either need to modify the script (loop count) before reboot, so it would be a self modifying code, or use some variable (perhaps SET SomeName=SomeName+1) to keep the count.

Does anyone know any examples? (don't want to re-invent the wheel if I don't have to)

Any common scripting language should be fine, though my current scripts (just looping) are written in powershell and in ironpython.

TIA


Posted

Put the script in the registry run key, write a registry entry somewhere for your countdown. Delete the run key value after reaching zero.

Or put it in the runonce or runonceex key and rewrite it to the runonce key after each run until the count is zero, again tracking via a registry value.

Posted

With IcemanND solution, you'll also need autologon enabled and use sysinternals autologon.

There are other ways to do this:

- creating a service that will run your script with sc and srvany.exe (from the 2003 Reskit) or using nssm and be removed after.

- creating a scheduled task which will run a each computer startup until you don't need it anymore.

Posted

True, autologon would be needed, he would need it for his initial thoughts also.

Getting scripts to run as desired can be tricky when done as a service. The Scheduled task at startup is a nice idea though, depends upon what he needs to do and under what user context.

Posted

Thanks for the great ideas.

The programs I want to run are a couple of console mode executables with their outputs redirected into a log file.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...