Shut down script (eventually) running on PCs that are turned off
I'm trying to use the built in Offline KScript to shut down a Windows PC for the following:
* Runs every night at 10pm to shut down any PCs that people are leaving on.
* Run manually to shut down PCs I woke up (using WOL) to work on in the evening.
I assumed that this script would only run on the PCs that are turned on, but it seems to run on the machines that are off the next time they are turned on. So people are booting up and their PC wants to immediately shut down. Does this make sense? Should I change this to a different kind of script? Is there a way that I can build a smart label for PCs that are turned on?
* Runs every night at 10pm to shut down any PCs that people are leaving on.
* Run manually to shut down PCs I woke up (using WOL) to work on in the evening.
I assumed that this script would only run on the PCs that are turned on, but it seems to run on the machines that are off the next time they are turned on. So people are booting up and their PC wants to immediately shut down. Does this make sense? Should I change this to a different kind of script? Is there a way that I can build a smart label for PCs that are turned on?
0 Comments
[ + ] Show comments
Answers (6)
Please log in to answer
Posted by:
GillySpy
13 years ago
An offline script will run at the next available time so you should have some checking in your script for the local time. Like this if you were doing a batch:
This way the script may run at 9am but do nothing.
@echo off
REM this will only shutdown the machine if the time is from 6pm to 7:59am
REM echo %time%
FOR /F "delims=:" %%j in ('echo %time%') do set i=%%j
goto checkhour
:checkhour
echo %i%
if "%i%"=="18" goto runshutdown
if "%i%"=="19" goto runshutdown
if "%i%"=="20" goto runshutdown
if "%i%"=="21" goto runshutdown
if "%i%"=="22" goto runshutdown
if "%i%"=="23" goto runshutdown
if "%i%"=="0" goto runshutdown
if "%i%"=="1" goto runshutdown
if "%i%"=="2" goto runshutdown
if "%i%"=="3" goto runshutdown
if "%i%"=="4" goto runshutdown
if "%i%"=="5" goto runshutdown
if "%i%"=="6" goto runshutdown
if "%i%"=="7" goto runshutdown
goto end
:runshutdown
echo %time%
REM "%windir%\system32\shutdown.exe" -s -f -c "" -t 180
:end
This way the script may run at 9am but do nothing.
Posted by:
RichB
13 years ago
Posted by:
GillySpy
13 years ago
Posted by:
ronco
13 years ago
Posted by:
RichB
13 years ago
Posted by:
GillySpy
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.