aurgathor Posted September 1, 2012 Posted September 1, 2012 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
IcemanND Posted September 1, 2012 Posted September 1, 2012 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.
allen2 Posted September 1, 2012 Posted September 1, 2012 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.
IcemanND Posted September 1, 2012 Posted September 1, 2012 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.
aurgathor Posted September 5, 2012 Author Posted September 5, 2012 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now