Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reboot? Are you SURE? 1

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
Hi

On two PCs we have in meeting rooms I'd like to prevent users from summarily powering off the PC. I don't want to completely forbid it, just say 'Are you SURE?' so that people don't routinely shut it down thus making it harder for the next user to use the PC.

A Shutdown script seemed ideal for this but the 'Shutdown /a' command I scripted doesn't work because the Shutdown script runs too late for it to work.

So, I've created a GPO with Loopback Processing enabled to run it as a Logoff script, but A) the script runs twice! and B) the 'Shutdown /a' command doesn't work anyway.

Is there a problem with my code or is there just a better way?

Code:
option explicit
'on error resume next
' Created: 12/04/2012

Const strVersion = "1.00"
Dim objShell : Set objShell = CreateObject("WScript.Shell")
Dim strComputer : strComputer = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
Dim strUser : strUser = objShell.ExpandEnvironmentStrings("%USERNAME%")

Dim msg
msg = "This Meeting Room PC should be left POWERED ON and " 	&_
	  "LOGGED ON with the local computer account " 				&_
	  ucase(strComputer) & "\meeting_" & right(strComputer,1) 	&_
	  " so that it's ready to use in the next meeting." 			& vbCrLf & vbCrLf &_
	  "Do you REALLY want to power off/reboot?"

Dim b : b = MsgBox(msg,vbYesNo,"Really?")

Select Case b
	Case vbYes
		' Allow the reboot/power-down to continue
	Case vbNo
		' Cancel the Windows reboot/power-down
		objShell.Run "shutdown /a"
End Select

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
 
I'm no expert at this but I think the shutdown -a command will only abort the shutdown command from the command line. I have also tested it against another shutdown utility (psshutdown) and shutdown won't abort psshutdown and vice versa



 
I think you may be right.

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
 
I'm don't know much about group policy as I don't get to administer it in my role but here's a wacky idea I've thought of that may work

1) If group policy can do this, remove the option for shutdown and restarting from the menus and windows security box, leaving only the log off option (if needed)

2) Place a script on the desktop to shutdown/restart that they can use if required.

The advantage of a script is that you can have the "Are you sure ? " option and if need be put some code in there to notify you of a shutdown or restart if you need to be notified



 
Yes, that is pretty much what I've already done (using Loopback processing), although as the usual account in use on that PC is a local account rather than a domain account I've had to duplicate the domain GPO with a Local Policy edit.

Have also considered the script idea but probably won't do that as people will still shut it down when they shouldn't plus it doesn't look good!

Cheers, TTTC.

JJ
[small][purple]Variables won't. Constants aren't[/purple]
There is no apostrophe in the plural of PC (or PST, or CPU, or HDD, or FDD, or photo, or breakfast...and so on)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top