Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: cannot shutdown after using shutdown script

04 Jan 2013   #1

Windows 7 Professional 32-bit
 
 
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 System SpecsSystem Spec
.

04 Jan 2013   #2

Microsoft Community Contributor Award Recipient

Win 7 Pro 64-bit
 
 

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 System SpecsSystem Spec
05 Jan 2013   #3

Windows 7 Professional 32-bit
 
 

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 System SpecsSystem Spec
.


05 Jan 2013   #4

Microsoft Community Contributor Award Recipient

Win 7 Pro 64-bit
 
 

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   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 System SpecsSystem Spec
05 Jan 2013   #5

Microsoft Community Contributor Award Recipient

Windows 8.1 Pro with Media Center
 
 

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:

Name:  Command_Shutdown_13.png
Views: 10
Size:  3.1 KB

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 System SpecsSystem Spec
05 Jan 2013   #6

Win 7 Pro x64 SP1, Win 7 Ult x86 SP1
 
 

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
Quote:
It was saved on a text file, and loaded using gpedit.msc.
My System SpecsSystem Spec
05 Jan 2013   #7

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
05 Jan 2013   #8

Microsoft Community Contributor Award Recipient

Windows 8.1 Pro with Media Center
 
 

Quote   Quote: Originally Posted by Duzzy View Post
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 System SpecsSystem Spec
05 Jan 2013   #9

Windows 7 Ultimate x64
 
 

Quote   Quote: Originally Posted by Kari View Post
Quote   Quote: Originally Posted by Duzzy View Post
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?.
Quote   Quote: Originally Posted by Kari View Post
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 System SpecsSystem Spec
05 Jan 2013   #10

Microsoft Community Contributor Award Recipient

Windows 8.1 Pro with Media Center
 
 

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 System SpecsSystem Spec
Reply

 cannot shutdown after using shutdown script




Thread Tools



Similar help and support threads for2: cannot shutdown after using shutdown script
Thread Forum
Single Monitor shutdown script Customization
Solved Logoff script not running at shutdown General Discussion
VBS script that shutdown other pc in network. Network & Sharing
Don't want shutdown script to run on restart Software
Is there a way to execute a prgm/script at user logoff/shutdown? General Discussion
Easy way to run script at shutdown without gpedit? General Discussion

Our Sites

Site Links

About Us

Find 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 03:09 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33