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
JAYBEEV

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
marsmimar

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
JAYBEEV

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
marsmimar

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
Kari

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: 13
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
DavidE

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
Duzzy

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
Kari

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
Duzzy

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
Kari

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
Thread Forum
Wanting a Script or Program to shutdown PowerDVD13 after ripped movie
Is there anyone that can create some sort of script or small program that could possibly stay alive in the background, watch for when powerdvd13 starts in cinema mode and when the movie stops, have the program shutdown PDVD and bring WMC to the front? - BACKGROUND - -Front End- I am using...
Media Center
Single Monitor shutdown script
Hi I have recently started using multiple monitors but due to my second monitor having a VGA connection it defaults to the primary display when starting up and it shows the bios and windows log on and only once windows has started will it revert back to my DVI primary display. My question is:...
Customization
Logoff script not running at shutdown
I have a script that launches Ccleaner and needs to run at shutdown. Shutdown scripts do not run within the user space as I understand, so I figured I'd use a logoff script which will run while the user is still logged in. The logoff script works when logging off as expected, but does not run...
General Discussion
VBS script that shutdown other pc in network.
Hi, I got an VBS script to shutdown pc in network remote.. Option Explicit Dim objShell, strComputer, strInput Dim strShutdown Do strComputer = (InputBox("Computer name", "Computer Name")) If strComputer <> "" Then
Network & Sharing
Don't want shutdown script to run on restart
Hi, I've got my system configured via gpedit so that it runs a custom batch script when it shuts down. The script can take about a minute to complete because it is telling some external hardware to run through its power down procedure. However when I tell the system to _reboot_ the script...
Software
Is there a way to execute a prgm/script at user logoff/shutdown?
In old WinXP there was a tricky feature in Group Policy editor to execute a script when a User logs off resp. the computer was shutdown. I do not find this feature in Windos 7 (pro). is there another way to execute a *.bat batch script at a) user logoff b) shutdown? Peter
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 22:26.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App