Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a script I want to deploy on my XP workstations as a shutdown script. I know I can add my script as a shutdown script with the UI (gpedit.msc), but I want to automate the deployment of my script. My workstations are not part of a Windows domain. I will deploy with OCS Inventory.

I tried to add entries to the Windows registry, but this doesn't work. I don't see what I added when I run gpedit.msc. If I add something with gpedit.msc, this seem to overwrite what I added manually into the registry.

share|improve this question
up vote 1 down vote accepted

I got it working...

I added the script with gpedit.msc on one computer. I exported registry keys from HKLM\Software\Policies\Microsoft\Windows\System\Sctipts and HKLM\Software\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine. I also zipped the C:\WINDOWS\SYSTEM32\GroupPolicy directory.

On another computer, I patched the registry with my 2 .reg files I exported earler on my first computer. I also unzipped my zip file to the same location on the second PC.

The script is running on shutdown and I see it in gpedit.msc. Everything seem to be good!

share|improve this answer

You can add keys here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown

Look here for more information:

You will just have to make a reg file that will run on all your machines to add the key to the registry.

share|improve this answer
This was not working. The entries seem to be duplicated in the windows registry. I also found similar keys in HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Shutdown. Should I add both entries in the registry? – Francis Apr 10 '12 at 19:50
Mmm doesn't work better. The entry is not shown on the gpedit.msc UI and if I add something there this overwrite what I added in the registry. Seem like there is some caching somewhere... – Francis Apr 10 '12 at 20:08

We'll pretend our startup script is located at C:\MyStartupScript.bat

You need a REG_SZ registry entry called Script with its value set to C:\MyStartupScript.bat located at both of the following two locations:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0\0


You also need the following entry in C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Scripts.ini


For a shutdown script, follow the same instructions but replace every instance of the word Startup with the word Shutdown


Looks like you may need to create two other registry entries as well if they don't already exist.

You'll need to create them in both of the registry locations mentioned above.

The first entry is a REG_SZ entry called Parameters and its value can be left empty.

The second entry is a REG_QWORD entry called ExecTime and its value is set to 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

In Windows XP, the REG command can't add a REG_QWORD entry to the registry.

To get around this limitation, I, for example, use a batch file that adds these lines

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Startup\0\0]

to a file called addQword.reg then executes the file using using this command:

regedit /s addQword.reg
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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