Automate creation of Windows startup script?
Posted
by Niten
on Server Fault
See other posts from Server Fault
or by Niten
Published on 2010-05-17T01:57:25Z
Indexed on
2010/05/17
2:01 UTC
Read the original article
Hit count: 351
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, or otherwise (even COM or 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:
HKLM\Software\Policies\Microsoft\Windows\System\Scripts\Startup
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:
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'sWin32_ScheduledJob
interface looks unreliable (it fails to show any of my currently scheduled tasks, for one thing).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...
© Server Fault or respective owner