Shutdown script problem

fehmi

Member
Joined
Jan 10, 2013
Posts
11
Hi all,

I want to execute a program at shutdown and I have added a small batch file to the local group policy editor - see the attached screenshot. What the batch file does is fairly simple, it sends a shut down signal to my wireless Xbox 360 controller. Double-clicking the batch file turns the controller off just fine so I know it works. When I add the batch file to the policy editor, the batch file is executed and the controller is turned off. However, when I shut down the computer, the controller does not turn itself off and I need to remove the batteries.

I would like to learn if there is a difference in the way shutdown scripts are executed at computer shutdown or restart. Also, is it possible to see whether this batch file was executed in the event logs?

Running Windows 8 Professional 64 bit

Thanks!
Fehmi
 

Attachments

  • Clipboard01.jpg
    Clipboard01.jpg
    63.5 KB · Views: 9
I don't have much experience with the group policy editor, but I am looking into this for you. Please be patient as I try to learn how the scripts work. I created a simple script, and I am also having problems with it not running during shutdown. I will let you know if/when I find a solution.


Update:

I was able to get my simple script working. Turns out the original script required elevated privileges to run, and that was why it was not running. Does your script require elevated mode?

To see if yours is working, try piping it to a file. For example, I ran ipconfig on shutdown, and my .bat file looked like:
Code:
ipconfig>"C:\Users\Mike\Documents\ipconfig.txt" 2>&1

Also, something I've learned from experience over the years with writing scripts is that your .bat file cannot be named the same as the command being run. For instance, my .bat file was called myipconfig.bat instead of ipconfig.bat​
 
Last edited:
Thanks for the suggestions and feedback! So I found out that a script executed at log-off did the trick in my case. Apparently the previous script seemed to be executed both at restart and shutdown but my Xbox controller was only turned off at a restart. Maybe the driver is unloaded from the memory before the shutdown script is executed - this is a mystery to me.

So I put the same batch file as a log off script and the controller turns itself off this time. I am not sure if I had this issue on Windows 7 - though I dont remember having to take the batteries off from the controller to turn it off.
 
Get the script to wait for a certain delay time to test and you might be able to pinpoint the error that way. I don't even own an Xbox so I don't know anything about it.

In Windows 8 though if you're having permission issues you may be able to invoke the Admin account to run the script with RunAs.exe.

There is a /WAIT flag for the start command in cmd.exe though: Start - Start a program | SS64.com

If it came down to it you could always invoke RunAs.exe with params using start, and which would also enable you to use the /WAIT flag too. If Shutdown.exe was working too fast, you could, create a script to call shutdown -a on shutdown, and create your own shutdown timer before the system would shut off (Otherwise, incorporate shutdown into your main script itself after everything was completed).

Just little tricks.

~Ace
 
Last edited:
Get the script to wait for a certain delay time to test and you might be able to pinpoint the error that way. I don't even own an Xbox so I don't know anything about it.

In Windows 8 though if you're having permission issues you may be able to invoke the Admin account to run the script with RunAs.exe.

There is a /WAIT flag for the start command in cmd.exe though: Start - Start a program | SS64.com

If it came down to it you could always invoke RunAs.exe with params using start, and which would also enable you to use the /WAIT flag too. If Shutdown.exe was working too fast, you could, create a script to call shutdown -a on shutdown, and create your own shutdown timer before the system would shut off.

Just little tricks.

~Ace

I believe this has something to do with the timing of the shutdown process but it is weird that the script can turn the controller off during restart but it doesn't work at shutdown. However, after adding the batch file as a log-off script, everything seems to work just fine!

Thanks for mentioning about the wait flag - I will give it a try if I encounter any other problems.

Fehmi
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top