cannot shutdown after using shutdown script

Page 2 of 2 FirstFirst 12

  1. Posts : 640
    Windows 7 Ultimate x64
       #11

    That's cool, your post is valid nonetheless.
      My Computer


  2. Posts : 7
    Windows 7 Professional 32-bit
    Thread Starter
       #12

    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.
      My Computer


  3. Posts : 640
    Windows 7 Ultimate x64
       #13

    JAYBEEV said:
    @Duzzy: I tried to run the shutdown command from the prompt, but the effect is the same.
    Not sure if you mean you tried "shutdown -a" or "shutdown -s" from the command promt but just to be clear like Kari said
    Kari said:
    If no delayed shutdown process is active, the shutdown -a does nothing:
    Kari said:
    Delayed shutdown after X seconds:
    Code:
    shutdown -s -t X
    Kari
    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.
    JAYBEEV said:
    @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.
    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.
    JAYBEEV said:
    @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"..
    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?
    JAYBEEV said:
    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.
    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
      My Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #14

    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:
    Code:
    menuSel=MsgBox("test", vbYesNo)
    The action occurs and the user cannot interact with it - thus the hang.

    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:
    cannot shutdown after using shutdown script-shutdown-reg.png
    and again here for a 64 bit OS
    cannot shutdown after using shutdown script-shutdown-reg2.png
    You might want to manually (and carefully) snoop around those areas to make sure that nothing is pointing to something.
      My Computer


  5. Posts : 10,485
    W7 Pro SP1 64bit
       #15

    @Duzzy, It took me so long to compose and post what I did - I missed seeing your post.

    Duzzy said:
    ~~~
    Another words the only way "shutdown -a" does anything is when "shutdown -t xx" has been ran to start a delayed shutdown. 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'm not picking at your declaration, just refining it.
    Test this in a batch file:
    Code:
    shutdown -s
    pause
    shutdown -a
    pause
    As long as there is some delay, (which shutdown -s has some delay), then you can abort.

    This does not abort
    Code:
    shutdown -s -t 0
    shutdown -a
    pause
    Duzzy said:
    ~~~
    I have preformed a couple quick test and you need to change another setting in gpedit to get it to display the message.....
    ~~~
    I don't know too much about GPO settings - what needs to be changed to allow user interaction with a shutdown script?
      My Computer


  6. Posts : 640
    Windows 7 Ultimate x64
       #16

    UsernameIssues said:
    The "no shutdown" behavior is repeatable using any line that requires user interaction. I tested inside a virtual machine using only this line:
    Code:
    menuSel=MsgBox("test", vbYesNo)
    The action occurs and the user cannot interact with it - thus the hang.
    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.
       Warning
    1. 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.
      My Computer


  7. Posts : 640
    Windows 7 Ultimate x64
       #17

    UsernameIssues said:
    I don't know too much about GPO settings - what needs to be changed to allow user interaction with a shutdown script?
    I was actually in the middle of writing a post explaining that as you posted check post #16 above.

    UsernameIssues said:
    Duzzy said:
    ~~~
    Another words the only way "shutdown -a" does anything is when "shutdown -t xx" has been ran to start a delayed shutdown. 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'm not picking at your declaration, just refining it.
    Test this in a batch file:
    Code:
    shutdown -s
    pause
    shutdown -a
    pause
    As long as there is some delay, (which shutdown -s has some delay), then you can abort.
    Opps I knew that, you are absolutely correct "shutdown -s" does provide a 1 min or so delay and I have modified my post to state that, thank you.
      My Computer


  8. Posts : 7
    Windows 7 Professional 32-bit
    Thread Starter
       #18

    Duzzy said:
    ...

    HideShutdownScripts

    Above two DWORD's under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" and

    ...
    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..
      My Computer


  9. Posts : 640
    Windows 7 Ultimate x64
       #19

    Good to hear you can shutdown normally.

    JAYBEEV said:
    Duzzy said:
    ...

    HideShutdownScripts

    Above two DWORD's under "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" and

    ...
    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.
    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.

    JAYBEEV said:
    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.
    I tried to explain earlier that it won't work because
    Duzzy said:
    ...."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.
    Also note
    Duzzy 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.
    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,
    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
    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.

    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.
      My Computer


  10. Posts : 640
    Windows 7 Ultimate x64
       #20

    I made some edits above if you have already read it.
      My Computer


 
Page 2 of 2 FirstFirst 12

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:19.
Find Us