Automatically add shutdown scripts

W

win2knovice

Hello
I need a particular script to be executed at reboot/shutdown time. I
believe this script needs to be added in the scripts.ini file in
%systemroot%\system32\grouppolicy\machine\scripts directory under
the Shutdown header. However this needs to be done programatically and
cannot be done via gpedit.msc.
Currently, I have compiled an executable that does the above. The
executable edits/creates the scripts.ini file in the same way as it
would be done via gpedit.msc.
But the problem I have is that it the script is not being executed in
all cases at shutdown time. For instance, in one machine I had to view
the script entry via gpedit.msc before the shutdown scripts started
working.
This made me believe that gpedit.msc needs to be executed atleast once
on a given machine

I did notice that whenever I viewed it via gpedit.msc , the
"Version" variable in gpt.ini at %systemroot%\system32\grouppolicy
is incremented. So I tried setting that variable to "0" (trying to
mimic the case where gpedit.msc has not yet been called on this
machine), but the script still got executed.

I would like to know the steps that I need to take to ensure that the
shutdown scripts are executed (whether or not gpedit.msc has been
opened on that machine ). Is there anything else done other than
editing the script.ini file when one uses gpedit.msc ? I did notice
that the timestamp on the scripts.ini changes when one only views the
entries in it via gpedit.msc, but the scripts.ini file did’t change.

Any help is greatly appreciated

Thanks
Adeep
 
Joined
Jul 15, 2005
Messages
1
Reaction score
0
You might find that the "version" you refer to is a sequence number.

My testing of editing the scritps.ini file shows that the scripts to be executed have to be numbered without gaps starting from 0.

Tom Collinge.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top