stalliondz
asked on
Warn the User that the PC will shutdown
Hello,
I have managed to solve my problem partially, thanks to bluntTony, as he provided me with a script that allows me to schedule a Shutdown task at a particular time to be executed and shut down the client PCs.
the the problem that Im facing now is that if I schedule it like that it will shut down the PC directly without any warning for the user, and if by chance an employee is still working late at the office and it comes to the time that it is scheduled for the PC to be turned off, it will shut down and all his work will be lost.
I have attached the VB code provided by bluntTony and what Im looking for now is a way to warn the user 15 min before the shutdown action, and allow him to Cancel it when needed.
I have managed to solve my problem partially, thanks to bluntTony, as he provided me with a script that allows me to schedule a Shutdown task at a particular time to be executed and shut down the client PCs.
the the problem that Im facing now is that if I schedule it like that it will shut down the PC directly without any warning for the user, and if by chance an employee is still working late at the office and it comes to the time that it is scheduled for the PC to be turned off, it will shut down and all his work will be lost.
I have attached the VB code provided by bluntTony and what Im looking for now is a way to warn the user 15 min before the shutdown action, and allow him to Cancel it when needed.
Set objShell = CreateObject("Wscript.Shell")
set objWMI = GetObject("winmgmts:\\.\root\cimv2")
set colScheduledJobs = objWMI.ExecQuery("Select * from Win32_ScheduledJob")
For each objJob in colScheduledJobs
If InStr(UCase(objJob.command),"SHUTDOWN") > 0 Then booFound = True
Next
If Not booFound Then objShell.Run("%systemroot%\system32\at 19:00 shutdown.exe -s -f -t 30")
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
anuroopkoka2005 thanks for the quick responce but that's not what i was looking for. as using that way i will have to create a file for all the Client PCs inthe company, and they just keep changing. can't keep on updating that on a daily basis.
where as the way i am using, i will just have to run it through the GPO as a startup script and that's it.
thanks Akhater as i didn't know that that value is the Seconds. and i will change it. But is there anyways that could give the user the ability to Cancel the shutdown if he's still working ???? that's what i need.
where as the way i am using, i will just have to run it through the GPO as a startup script and that's it.
thanks Akhater as i didn't know that that value is the Seconds. and i will change it. But is there anyways that could give the user the ability to Cancel the shutdown if he's still working ???? that's what i need.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Description of the Shutdown.exe Tool
Shutdown.exe uses the following syntax:
shutdown \\computername /l /a /r /t:xx "msg" /y /c
You can use the following switches with Shutdown.exe:
\\computername: Use this switch to specify the remote computer to shut down. If you omit this parameter, the local computer name is used.
/l (Note that this is a lowercase "L" character): Use this switch to shut down the local computer
/a: Use this switch to quit a shutdown operation. You can do this only during the time-out period. If you use this switch, all other parameters are ignored.
/r: Use this switch to restart the computer instead of fully shutting it down.
/t:xx: Use this switch to specify the time (in seconds) after which the computer is shut down. The default is 20 seconds.
"msg": Use this switch to specify a message during the shutdown process. The maximum number of characters that the message can contain is 127.
/y: Use this switch to force a "yes" answer to all queries from the computer.
/c: Use this switch quit all running programs. If you use this switch, Windows forces all programs that are running to quit. The option to save any data that may have changed is ignored. This can result in data loss
Shutdown.exe uses the following syntax:
shutdown \\computername /l /a /r /t:xx "msg" /y /c
You can use the following switches with Shutdown.exe:
\\computername: Use this switch to specify the remote computer to shut down. If you omit this parameter, the local computer name is used.
/l (Note that this is a lowercase "L" character): Use this switch to shut down the local computer
/a: Use this switch to quit a shutdown operation. You can do this only during the time-out period. If you use this switch, all other parameters are ignored.
/r: Use this switch to restart the computer instead of fully shutting it down.
/t:xx: Use this switch to specify the time (in seconds) after which the computer is shut down. The default is 20 seconds.
"msg": Use this switch to specify a message during the shutdown process. The maximum number of characters that the message can contain is 127.
/y: Use this switch to force a "yes" answer to all queries from the computer.
/c: Use this switch quit all running programs. If you use this switch, Windows forces all programs that are running to quit. The option to save any data that may have changed is ignored. This can result in data loss
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks alot guys, that was exactly what i needed.
Best Regards
Best Regards
ASKER
Thanks for the efforts, Really helpfull
using PSShutdown.exe u can even reboot, shutdown, log off, u can do it forcefully...
This PSshutdown will prompt for saving the file the user is currently working on... By default this script will reboot only..if u want to shutdown just change the arguement u pass on to...
It will take the machine name as input from the txt file...
This script genetates report...download the psshutdown.exe from the internet...
Open in new window