New
#11
That's cool, your post is valid nonetheless.
Thanks guys, I appreciate all the efforts.
@marsmimar: I didn't find the registry key that you described. The shutdown command also does not work when run from the command prompt.
@kari: I didn't notice that error.. but still, that was not the problem. In fact, I believe the script was supposed to display a message box, but it doesn't.. when I click the shutdown button, it just closes everything, and then logoff, then displays the "shutting down" message but doesn't turn the computer off. I tried waiting up to 5 minutes... still nothing.
@DavidW7ncus: I really don't know what to look for in the policy editor.. and as far as I see, everything seems to be "not configured"..
@Duzzy: I tried to run the shutdown command from the prompt, but the effect is the same.
Just like marsmimar's idea, I think adding the script changed something in the registry, but I don't know where to start looking.. It seems too simple, but I want to do the repair install when everything else fails.. any more ideas? Thanks.
Not sure if you mean you tried "shutdown -a" or "shutdown -s" from the command promt but just to be clear like Kari said
Another words the only way "shutdown -a" does anything is when "shutdown -t xx" has been ran to start a delayed shutdown or "shutdown -s" as this also provides a 1 minute or so delay. When you click Shutdown on the start menu or press the power button on the PC it immediately starts to shutdown with no delay.
I have preformed a couple quick test and you need to change another setting in gpedit to get it to display the message but "shutdown -a" does not work even if it's the first command in the script because of the my words above and the fact that the script is ran too late into the shutdown process.
Have you double checked that your script has been removed from the shutdown scripts and maybe the logoff scripts if you played around trying to get it to work?
I tested the same script on my testing installation to see if I could reproduce your problem but I did not have any problems shutting down after the script was removed. While the script was set up to run it would hang on shutdown untill you clicked yes or no on the message and because you can not see the message it will probably hang indefinitely. With verbose shutdown enabled it hung on "Please wait for the Group Policy Client", so again I would double check that your script has been removed.
Last edited by Duzzy; 07 Jan 2013 at 09:34. Reason: Mistake
Please post the contents of these files:
"%SystemRoot%\system32\GroupPolicy\gpt.ini
"%SystemRoot%\system32\GroupPolicy\Machine\Scripts\scripts.ini
The "no shutdown" behavior is repeatable using any line that requires user interaction. I tested inside a virtual machine using only this line:
The action occurs and the user cannot interact with it - thus the hang.Code:menuSel=MsgBox("test", vbYesNo)
I wonder why MS just did not process a logoff and then a shutdown? I guess that takes too long.
Anyway, when I set a shutdown script via gpedit, it changed these areas of the registry:
and again here for a 64 bit OS
You might want to manually (and carefully) snoop around those areas to make sure that nothing is pointing to something.
@Duzzy, It took me so long to compose and post what I did - I missed seeing your post.
I'm not picking at your declaration, just refining it.
Test this in a batch file:
As long as there is some delay, (which shutdown -s has some delay), then you can abort.Code:shutdown -s pause shutdown -a pause
This does not abort
I don't know too much about GPO settings - what needs to be changed to allow user interaction with a shutdown script?Code:shutdown -s -t 0 shutdown -a pause
I would like to just note for anybody that comes across this thread that you can interact with a script by changing a setting in gpedit under,
Computer Configuration > Administrative Templates > System > Scripts
Here you'll find "Run shutdown scripts visible" and "Run Startup scripts visible". Change both or only the one you need to interact with. Also under,
User Configuration > Administrative Templates > System > Scripts
You'll find "Run logon scripts visible" and "Run logoff scripts visible".
For those with Windows versions without access to gpedit I believe there are ways to run shutdown scripts but I don't know about other scripts or interacting with them. Interaction maybe possible by adding the registry values which are all DWORD's with their data value set to 0.
Warning1. Any changes to the registry could result in a non-working computer.
2. If the registry change does not enable interaction the system will hang during the running of the script and a forced reboot will be required.
3. If the script is a startup or logon then it will be ran again after a forced reboot so I would not recommend trying either of these
EDIT
I did find a setting in gpedit that suggest the maximum hang time while processing a script would be 10mins unless changed. Read more for "Maximum wait time for Group Policy scripts" under,
Computer Configuration > Administrative Templates > System > Scripts
I claim no responsibility if you cannot boot.
END EDIT
HideStartupScripts
HideShutdownScripts
Above two DWORD's under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" and
HideLogoffScripts
HideLogonScripts
DWORD's under "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System"
These registry keys are for 64bit Windows. 32bit bit I would think are the same but I take no responsibility for errors.
Last edited by Duzzy; 08 Jan 2013 at 06:15.
The good news is, this one worked! I added this to my registry, and now I can see the message and shutdown. I also tried removing the script, and it also shuts down properly.
Thank you very much.
The bad news is, the Yes/No option in the message doesn't work.. Both "Yes" and "No" proceeds to a shutdown. I even tried adding an else statement to the script, "shutdown -a", but it didn't work.
well, at least now I can shutdown properly.. hahaha..
Good to hear you can shutdown normally.
You should have been able to enable this by gpedit, although it probably doesn't really matter adding it straight to the registry will not tell you that it is enabled when viewing in gpedit.
I tried to explain earlier that it won't work because
Also note
If you would like to use a shortcut to shutdown the PC you can use a script that ask the questions and if ok then shutdown using "Shutdown -s" or "shutdown -s -t xx" or if something has been forgotten do nothing or display a message that shutdown has been aborted. For example,
You may need to re-word your questions as to me it reads yes, yes, no or no, no, yes, so I wasn't sure if you wanted to shutdown on a yes or no.Code:Set WshShell=WScript.CreateObject("WScript.Shell") On Error Resume Next menuSel=MsgBox("Have you completed your timesheet ?" & vbCrLf & "Have you sent in the Invoice?" & vbCrLf & "Have you forgotten anything at all?" & vbCrLf & "Think hard!", vbYesNo) If menuSel=vbNo Then WshShell.Run "Shutdown -s" Else MsgBox "Shutdown has been aborted", vbOKOnly End If
The way I've written the script is if you click No it shutdowns with a 1min or so delay giving you time to manually abort with "shutdown -a" or if you click Yes it displays "Shutdown has been aborted" in a message box. To shutdown without delay use "shutdown -s -t 0" or to add more delay use "shutdown -s -t xx" replacing xx with the number of seconds you wish to delay for. I recommend at least the 1min delay in case you click the wrong button you can abort it.
To prevent using Shutdown from the Start Menu you can remove it via gpedit by enabling "Remove and prevent access to the Shut Down, Restart, Sleep, and Hibernate commands" found under,
User Configuration > Administrative Templates > Start Menu and Taskbar
This will only remove the commands from the Start Menu and the page that displays when you press "Ctrl + Alt + Del", this will not prevent other ways including software set to shutdown. Although this all works for shutting down I don't know any way to prevent logging off or a way to log off via a script if that matters
EDIT but you can remove logoff from the start menu or all ways to log off.
To remove logoff from start menu use "Remove logoff on the Start Menu" in the same path as above or to remove all ways use "Remove logoff on the Start Menu" and "Remove Logoff" under
User Configuration > Administrative Templates > System > Ctrl + Alt + Del Options
END EDIT
To prevent shutting down by the PC's power button set the action in the Advanced Power Settings in the Power Options for the power plans you use.
One last thing I did find a setting in gpedit that suggest the maximum hang time while processing a script would be 10mins unless changed. Read more for "Maximum wait time for Group Policy scripts" under,
Computer Configuration > Administrative Templates > System > Scripts
Last edited by Duzzy; 08 Jan 2013 at 06:36. Reason: Additional info.