Is there a good way to automate installing local startup (rather than login) scripts in Windows XP and Windows 7, via the command line, WMI, COM, or otherwise (even Win32 if it comes to that)?

I need to setup a local startup script on a large number of computers, and unfortunately, Active Directory is absolutely not an option. I would like to write a script or small program that I can run on each computer to perform the startup script installation in order to save myself a lot of error-prone point-and-click manual labor.

I see that when one uses gpedit.msc to create a local startup script, information about the script gets stored in the registry here:


However, if you create such a script and then delete its registry key, the script will remain listed in the local Group Policy editor; as is so often the case in Windows, apparently there is more going on there than meets the eye. This leads me to question whether it's safe to manually add subkeys for new startup scripts here (I wouldn't want my script to be overwritten by later changes made using the local Group Policy editor, for instance)...

Another option that's occurred to me is to create an item in the Task Scheduler configured to run at system startup. However, my concerns there are twofold:

  1. Can this be automated any more easily? For instance, the at command doesn't appear to let you schedule a task for system startup, and WMI's Win32_ScheduledJob interface looks unreliable (it fails to show any of my currently scheduled tasks, for one thing).

  2. Would I be able to prevent users from logging in until the scheduled startup task is completed, as can be done with "normal" Windows startup scripts?

Thanks in advance for any suggestions, I've been banging my head against this one for a bit...


Create a scheduled task that fires on system start-up. Automate this using SCHTASKS.EXE. The schedule type you want is ONSTART.


Try copying the two folders in C:\Windows\System32\GroupPolicy to the new computer, rebooting and running gpupdate /force

If you want to try the scheduled task way use Schtasks. It's more robust than at and can let you choose the logon option. However, it doesn't wait for it to complete before you logon.


I never found a clean solution to this. The following approach is messy, but it worked for my purposes:


  • Unfortunately, that link is dead. – Hans Aug 6 '14 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.