+ Post New Thread
Results 1 to 11 of 11
Windows Thread, Startup scripts in Technical; What would be the best way to make a startup script run once as opposed to every time the machine ...
  1. #1

    Join Date
    Oct 2007
    Location
    Cambridgeshire, UK
    Posts
    248
    Thank Post
    48
    Thanked 20 Times in 18 Posts
    Rep Power
    12

    Startup scripts

    What would be the best way to make a startup script run once as opposed to every time the machine boots?

    I am using a script (based on fragments from these forums) to load printer drivers (and intend to add: setting default power settings, and add/removing devices) post deployment but this currently runs at every boot.

    This means that each machine takes longer to get to the logon screen (even longer for laptops when working offline). I'd like the script to only run once following deployment. I know I could disable the appropriate GPO but I'd like a more automated method - maybe as part of the WDS/Sysprep stage.

    Thanks, Dave.

  2. #2


    Join Date
    Feb 2007
    Location
    Northamptonshire
    Posts
    4,411
    Thank Post
    322
    Thanked 715 Times in 644 Posts
    Rep Power
    199
    Perhaps package the script as a msi which goes out as part of the build in AD thus allowing you also some version control for the future.

    Alternatively, at the end of the script make a reg entry and in future have the script initially check if this reg entry exists or exit.

  3. #3

    Join Date
    Nov 2006
    Location
    Kendal
    Posts
    1,509
    Thank Post
    94
    Thanked 168 Times in 136 Posts
    Rep Power
    65
    Quote Originally Posted by djones View Post
    What would be the best way to make a startup script run once as opposed to every time the machine boots?

    I am using a script (based on fragments from these forums) to load printer drivers (and intend to add: setting default power settings, and add/removing devices) post deployment but this currently runs at every boot.

    This means that each machine takes longer to get to the logon screen (even longer for laptops when working offline). I'd like the script to only run once following deployment. I know I could disable the appropriate GPO but I'd like a more automated method - maybe as part of the WDS/Sysprep stage.

    Thanks, Dave.
    Why not make the script write a txt file to the c drive (script_has_run.txt for example) then get the script to check for the existance of that tx file. If it exists on the c drive the script just exits - if it doesn't exist the script runs. That way it should run once, write the text file then not run on next boot.

  4. #4

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,852
    Thank Post
    412
    Thanked 773 Times in 646 Posts
    Rep Power
    168
    I'd like the script to only run once following deployment.
    Do this all in WDS then, it's neater. Put your script into the image somewhere (root of C:?) and call it in the registry with HKLM\Software\Microsoft\Windows\CurrentVersion\Run Once

    After it's run it's removed from the registry automagically.


    Edit: Backslashes. Spot the *nix boy
    Last edited by powdarrmonkey; 16th February 2008 at 01:02 PM.

  5. Thanks to powdarrmonkey from:

    djones (27th February 2008)

  6. #5

    mattx's Avatar
    Join Date
    Jan 2007
    Posts
    8,328
    Thank Post
    857
    Thanked 868 Times in 520 Posts
    Rep Power
    529
    What would be the best way to make a startup script run once as opposed to every time the machine boots?
    Use a flag file. [ As Jcollins has already stated ]
    I have a few scripts which only need to run once so the first time they are run I copy a file over in a location, then the script is run.
    The next time the script runs it checks for the file, if its there it won't run, if its not there, then it runs.
    You could also write a self deleting script...... [ I used to do that for my automated Win95 thin client builds many years ago..... ]

  7. #6

    Join Date
    Mar 2007
    Posts
    1,283
    Thank Post
    48
    Thanked 143 Times in 134 Posts
    Rep Power
    37
    we have various scripts that we use on a new computer in a new computer ou. Once the computer is on the network we add it to the new computer ou, reboot it severaltimes and that installs all the software we need and does any of the other stuff we need (usefull for if a small fix is made when its not worth creating a new image)

  8. #7

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,852
    Thank Post
    412
    Thanked 773 Times in 646 Posts
    Rep Power
    168
    In which case, why don't you have a thin RunOnce script that goes and fetches an up-to-date fat script from a network location? Then you don't have to do any bodging with GPO, or update your image every time there's a change.

  9. #8
    ajbritton's Avatar
    Join Date
    Jul 2005
    Location
    Wandsworth
    Posts
    1,641
    Thank Post
    23
    Thanked 75 Times in 45 Posts
    Rep Power
    29
    The script presumably 'does' something on the PC when it runs. Is it not possible to have the script 'detect' the status of the PC to decide if it needs to run or not? Failing that, I would tend to write an entry in the registry rather than to a file but that's just down to personal preference.

  10. #9

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,110
    Blog Entries
    2
    Thank Post
    110
    Thanked 511 Times in 443 Posts
    Rep Power
    114
    Quote Originally Posted by ajbritton View Post
    The script presumably 'does' something on the PC when it runs. Is it not possible to have the script 'detect' the status of the PC to decide if it needs to run or not? Failing that, I would tend to write an entry in the registry rather than to a file but that's just down to personal preference.
    We use a registry key (HKLM\software\<our name>) and there are various values under this. the startup script checks for the presence of the relevant value and runs each sub-routine as necessary.

    this makes it easy to make changes - eg a bit of code has been run on every machine but now I want a new version of it to run. I update the script so it checks for value "2" instead of "1" and updates the value once it's run.

  11. #10

    Join Date
    Oct 2005
    Location
    East Midlands
    Posts
    675
    Thank Post
    10
    Thanked 97 Times in 61 Posts
    Rep Power
    30

    Registry entry

    Yes I agree with the Registry method for setting the flag. If you are doing a new image then it probably worth to use the RunOnce settings as this should take care of it before the stations is commissioned to the user.

    Ash.

  12. #11

    Join Date
    Oct 2007
    Location
    Cambridgeshire, UK
    Posts
    248
    Thank Post
    48
    Thanked 20 Times in 18 Posts
    Rep Power
    12
    Quote Originally Posted by powdarrmonkey View Post
    Do this all in WDS then, it's neater. Put your script into the image somewhere (root of C:?) and call it in the registry with HKLM\Software\Microsoft\Windows\CurrentVersion\Run Once

    After it's run it's removed from the registry automagically.
    Thanks for all the replies, this is kinda what I have decided is going to be the best option for me in the short term at least. My scripting skills really aren't very hot to say the least and I'm really pushed for time at the moment even getting round to replying here!

    I think the way I'm going to try and do this is by utilsing a [GuiRunOnce] section in 'sysprep.inf' to call the script that installs the printer drivers (so that restricted user accounts can assign specific printers at login) and then add a call, to another script, in 'CmdLines.txt' to remove/reinstall problem devices (e.g. SCSI/RAID Host Controller). However, I've got a feeling that the execution of 'CmdLines.txt' post mini-setup and before first reboot may be too early for this purpose.

SHARE:
+ Post New Thread

Similar Threads

  1. RM CC3 Startup Script
    By randle in forum Windows
    Replies: 4
    Last Post: 30th July 2007, 02:56 PM
  2. Dreamweaver 8 startup Error
    By BKGarry in forum Educational Software
    Replies: 9
    Last Post: 26th June 2007, 01:33 PM
  3. 10min startup c/o whiteboard
    By Midget in forum Hardware
    Replies: 8
    Last Post: 30th November 2006, 07:29 PM
  4. IE6 trys to run an ISP setup on startup
    By pmassingham in forum Windows
    Replies: 1
    Last Post: 23rd March 2006, 11:20 AM
  5. Computer Startup Scripts
    By Spot in forum Windows
    Replies: 18
    Last Post: 17th November 2005, 12:06 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •