Solved

Set Group Policy Scripts (Shutdown) programatically

Posted on 2011-03-21
4
2,584 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create a path if not exists 7 67
Child Form in front 4 34
MsgBox 4 42
vbModal 12 30
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

948 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

20 Experts available now in Live!

Get 1:1 Help Now