Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

running script over reboot


  • Please log in to reply
4 replies to this topic

#1
aurgathor

aurgathor

    Junior

  • Member
  • Pip
  • 88 posts
  • Joined 24-January 06
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


How to remove advertisement from MSFN

#2
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • Joined 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag
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.

#3
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,814 posts
  • Joined 13-January 06
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.

#4
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • Joined 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag
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.

#5
aurgathor

aurgathor

    Junior

  • Member
  • Pip
  • 88 posts
  • Joined 24-January 06
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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users