Windows XP – Adding a Shutdown Script Without gpedit.msc or Active Directory

scriptingwindowswindows-xp

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.

Best Answer

To anyone struggling to get this working, my sympathy. I spent many hours trying to figure out exactly which of the hundreds of changes gpedit makes are actually important. My tests were conducted on Windows Server 2016. These turned out to be relevant:

  1. The values under:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\[Startup|Shutdown]\0
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\[Startup|Shutdown]\0\0
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\[Startup|Shutdown]\0
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\[Startup|Shutdown]\0\0
    
  2. The directories:

    \Windows\system32\GroupPolicy\Machine\Scripts\Startup
    \Windows\system32\GroupPolicy\Machine\Scripts\Shutdown
    

Windows uses those directories as the working directory for the scripts. Even if you don't keep your startup/shutdown scripts there, those directories need to exist.

Nothing else gpedit does seemed to matter. This includes many registry entries and the .ini files referenced in other answers. It's possible that some of the keys above are superfluous as well but I ran out of testing patience.