Solved

Set Group Policy Scripts (Shutdown) programatically

Posted on 2011-03-21
4
2,561 Views
Last Modified: 2012-05-11
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\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0\0
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\0\0
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Group Policy\Scripts\Shutdown\0\0
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Group Policy\State\Machine\Scripts\Shutdown\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
0
Comment
Question by:Axter
  • 3
4 Comments
 
LVL 6

Expert Comment

by:WhitePhantom
ID: 35184525
Are these computers a member of a domain?  It could be that the shutdown scripts configuration set by a domain group policy is trumping the local configuration.

WP
0
 
LVL 30

Author Comment

by:Axter
ID: 35191439
>>Are these computers a member of a domain?  It could be that the shutdown scripts configuration set by a domain group policy is trumping the local
>>configuration.


If that were the case, it would also happen when I made the changes through GPEdit.msc.
If GPEdit.msc can make the group policy changes on the local machine, than there should be a way to programatically make the change.s
0
 
LVL 30

Accepted Solution

by:
Axter earned 0 total points
ID: 35191489
I figured it out.
GPEdit.msc is getting the value from the following hidden file:
C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini

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.
0
 
LVL 30

Author Closing Comment

by:Axter
ID: 35275211
Found my own solution.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now