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
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\System\Scripts\Startup\0\0
You also need the following entry in C:\WINDOWS\system32\GroupPolicy\Machine\Scripts\Scripts.ini
[Startup]
0CmdLine=C:\MyStartupScript.bat
0Parameters=
For a shutdown script, follow the same instructions but replace every instance of the word Startup with the word Shutdown
edit:
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]
"ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
to a file called addQword.reg then executes the file using using this command:
regedit /s addQword.reg