cannot shutdown after using shutdown script

Page 1 of 2 12 LastLast

  1. Posts : 7
    Windows 7 Professional 32-bit
       #1

    cannot shutdown after using shutdown script


    Hello,

    I tried adding a shutdown script to my Windows 7 PC. The script is as follows:
    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=vbYes Then
        WshShell.Run "Shutdown -a"
    End If
    It was saved on a text file, and loaded using gpedit.msc.
    Unfortunately, it didn't work, so I removed it.
    The problem now is, my PC does not shutdown.

    How can I restore it to it's normal operation?

    Thanks.
      My Computer


  2. Posts : 10,994
    Win 7 Pro 64-bit
       #2

    Hello JAYBEEV and welcome to Seven Forums.

    I think the quickest fix is to restore your computer to a date/time prior to running the script.

    System Restore

    If you don't have any restore points, or if it doesn't work, you could try running a system file checker scan from an elevated command prompt (option two.) This will try to repair any damaged or corrupt system files. If problems are found, run the scan 3 times and reboot the computer after each scan.

    SFC /SCANNOW Command - System File Checker
      My Computer


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

    marsmimar,

    I didn't have any restore points, and the sfc reported no violations.. still, I can't shutdown properly.
    Any other suggestions?

    thanks.
      My Computer


  4. Posts : 10,994
    Win 7 Pro 64-bit
       #4

    See if this Shutdown Shortcut (option two in the tutorial) allows the computer to shutdown. If it does, you might consider pinning the shortcut to a convenient location (taskbar, system tray, etc) and using it.

    Shut Down Computer Shortcut - Create

    If it doesn't work I would suspect that something within the Registry has changed. My best guess is the "NoClose" value may have changed from 0 (zero) to 1 (one).
       Warning
    THIS IS ONLY A GUESS! Any changes to the registry could result in a non-working computer.
    Try navigating to the following registry key:

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer

    Click on Explorer and in the right panel see what vaue is assigned to NoClose. If it is 1 you could try changing it to 0. But I would strongly suggest creating a restore point prior to editing the registry.

    It might be safer to try a repair install. A repair install will try to fix your installed Windows 7 while preserving user accounts, customizations, system drivers, etc. A repair install will take about an hour. If successful you would have to reinstall Windows Updates which could take another hour or two.

    Repair Install

    I have to say again that editing the registry incorrectly could have very bad consequences.
      My Computer


  5. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #5

    An error in your script:

    Your script as you posted it first checks that you have not forgotten anything, then if not, it aborts an earlier timed shutdown using the abort switch -a with shutdown command.

    If no delayed shutdown process is active, the shutdown -a does nothing:

    cannot shutdown after using shutdown script-command_shutdown_13.png

    Change the switch in shutdown command from -a (abort) to -s (shutdown).

    To clarify: To stop executing an active delayed shutdown process (abort it):
    Code:
    shutdown -a
    To shutdown:
    Code:
    shutdown -s
    Delayed shutdown after X seconds:
    Code:
    shutdown -s -t X
    Kari
      My Computer


  6. Posts : 6,330
    Multi-Boot W7_Pro_x64 W8.1_Pro_x64 W10_Pro_x64 +Linux_VMs +Chromium_VM
       #6

    You could also try looking in the Group Policy editor to see if you can find something that your script changed.
    Just my wild guess of something I would check because you stated
    It was saved on a text file, and loaded using gpedit.msc.
      My Computer


  7. Posts : 640
    Windows 7 Ultimate x64
       #7

    Can't help with your current problem but it's my belief that Shutdown -a cannot abort a shutdown that has been started by clicking shutdown on the Start Menu or by pressing the power button and if the shutdown is started by a script it still won't work from the Startup/Shutdown Script section in gpedit.msc as the user is logged off and the shutdown process is too far in before scripts are run.

    Only way I could see it working is to change your script and use it from a shortcut to shutdown.

    Anybody feel free to correct me if I'm wrong.
      My Computer


  8. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #8

    Duzzy said:
    Can't help with your current problem but it's my belief that Shutdown -a cannot abort a shutdown that has been started by clicking shutdown on the Start Menu or by pressing the power button and if the shutdown is started by a script it still won't work from the Startup/Shutdown Script section in gpedit.msc as the user is logged off and the shutdown process is too far in before scripts are run.

    Only way I could see it working is to change your script and use it from a shortcut to shutdown.

    Anybody feel free to correct me if I'm wrong.
    Scroll two post up from your post...
      My Computer


  9. Posts : 640
    Windows 7 Ultimate x64
       #9

    Kari said:
    Duzzy said:
    Can't help with your current problem but it's my belief that Shutdown -a cannot abort a shutdown that has been started by clicking shutdown on the Start Menu or by pressing the power button and if the shutdown is started by a script it still won't work from the Startup/Shutdown Script section in gpedit.msc as the user is logged off and the shutdown process is too far in before scripts are run.

    Only way I could see it working is to change your script and use it from a shortcut to shutdown.

    Anybody feel free to correct me if I'm wrong.
    Scroll two post up from your post...
    I guess your referring to these two lines as it's basically what I said, although just changing from -a to -s is not going to help running it from gpedit so It's not actually incorrect info I gave is it?.
    Kari said:
    An error in your script:
    If no delayed shutdown process is active, the shutdown -a does nothing:

    Change the switch in shutdown command from -a (abort) to -s (shutdown).
      My Computer


  10. Posts : 17,545
    Windows 10 Pro x64 EN-GB
       #10

    My mistake, suffering from the worst hangover this millennium, writing confusing posts. Let's try to clarify:

    I did not take a stand on if this script of our OP's can or can not be run using GPEDIT. I was only showing him one simple error in his script and explaining what the -a switch in shutdown command does.

    Kari
      My Computer


 
Page 1 of 2 12 LastLast

  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 00:08.
Find Us