I'm looking for a way to set the local machine group policy shutdown script programatically.
I've tried modifying all of the following registry keys, but they seem to take no effect on what's displayed via gpedit.msc.
HKEY_LOCAL_MACHINE\SOFTWAR
E\Microsof
t\Windows\
CurrentVer
sion\Group
Policy\Scripts\Shutdown\0\
0
HKEY_LOCAL_MACHINE\SOFTWAR
E\Microsof
t\Windows\
CurrentVer
sion\Group
Policy\State\Machine\Scrip
ts\Shutdow
n\0\0
HKEY_LOCAL_MACHINE\SOFTWAR
E\Wow6432N
ode\Micros
oft\Window
s\CurrentV
ersion\Gro
up Policy\Scripts\Shutdown\0\
0
HKEY_LOCAL_MACHINE\SOFTWAR
E\Wow6432N
ode\Micros
oft\Window
s\CurrentV
ersion\Gro
up Policy\State\Machine\Scrip
ts\Shutdow
n\0\0
I do notice that if I change the script via gpedit.msc, the above registry keys get updated to the new value.
I've tried changing these registry keys, and than rebooting the computer, but after rebooting I still see the old value in gpedit.msc.
Moreover, when I shutdown the machine, it seems to be calling the old script instead of new script associated with the registry key changes.
Does anyone know how to change this policy through VB or C++?
gpedit.png
GPEdit.msc is getting the value from the following hidden file:
C:\Windows\System32\GroupP
Example content:
[Shutdown]
0CmdLine=MyScript.vbs
0Parameters=
Unless I have problems finding VB code to update an INI file, I'll be requesting to have this question close.