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?
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
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:
@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.
Answered 09/30/2011 by: GillySpy
Seventh Degree Black Belt

Please log in to comment
0
We use Online shutdown scripts instead of Offline, just for this reason.
Answered 09/30/2011 by: RichB
Fourth Degree Green Belt

Please log in to comment
0
An online script can be good but it takes resources away from the server. If it were my kbox I would be doing this type of task offline because of it's potential to go to many clients and for the agent to be offline, but there's definitely more than one way to skin a kat
Answered 09/30/2011 by: GillySpy
Seventh Degree Black Belt

Please log in to comment
0
Why not script the building of a Schedule Task (for Windows machines)? There's no ambiguity about when that would run. r2
Answered 10/06/2011 by: ronco
Second Degree Brown Belt

Please log in to comment
0
Then the user would not be able to stop the shutdown and we have allowed them to cancel our shutdown scripts.
Answered 10/06/2011 by: RichB
Fourth Degree Green Belt

Please log in to comment
0
you can build a scheduled task. my goal is that I simply want to take an existing script and "transform" it by checking the time first. The other tasks in the script could be complex. I do not want to have to rewrite it as a scheduled task (e.g. as one batch file)
Answered 10/06/2011 by: GillySpy
Seventh Degree Black Belt

Please log in to comment
Answer this question or Comment on this question for clarity