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?
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]
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]