Ok, so after tinkering a bit here's what I have.
A tool that you can set a time of day to shutdown your system, conditionally if none of your clients systems are alive.
This is so if you have a server you want to be off to save power but not have to shut it down yourself or worry it will shutoff on you while watching movies or recorded TV.
What I do is I use a Bios RTC alarm to turn on my monster every day at 5:20pm, then I run my sleepkeeper tools starting at 10pm if any of my clients are alive it will stay on and retest every few minutes until no clients are alive then it runs a log of all the files on all the drives it can find.
It keeps those logs for a week cycling through each weekday prior to over writing the log.
It will as if it's ok to shutdown but if you do not stop it it will shutdown automatically.
Should you interupt the auto shutdown it will wait 1/2 hour and test again.
As stated before this is a work in progress, use at your own risk, if you know scripting feel free to make suggestions.
Copy these lines into a notepad and save as sleepkeeper.cmd
Use task scheduler to run it nightly at 10pm.
If you need help or tweak I will try to help.
You will need sleep.exe which you can download here.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=enBegin script
*****************************************************************
@echo off
:start
cls
Rem *********************Sets time of Day**********************************
set HR=0
Set MN=0
Set AMPM=0
For /F "tokens=1,2,3 delims=: " %%A in ('time.exe /T') do (
set HR=%%A
set MN=%%B
set AMPM=%%C
)
Rem *********************************************************************
Rem *********************sets day of week**********************************
For /F "tokens=1 eol= " %%A in ('Date.exe /T') do (
set arg1=%%A
)
Goto %arg1%
goto exit
Rem *********************************************************************
rem ***************Sets test period for each day*******************************
:Mon
set DownTime=10
Set Downtimeperiod=PM
goto timer
goto exit
:Tue
set DownTime=10
Set Downtimeperiod=PM
goto timer
goto exit
:Wed
set DownTime=10
Set Downtimeperiod=PM
goto timer
goto exit
:Thur
set DownTime=10
Set Downtimeperiod=PM
goto timer
goto exit
:Fri
set DownTime=9
Set Downtimeperiod=AM
goto timer
goto exit
:Sat
set DownTime=10
Set Downtimeperiod=PM
goto timer
goto exit
:Sun
set DownTime=10
Set Downtimeperiod=PM
goto timer
goto exit
rem ********************************************************************
rem *****************compares time set with current time**********************
:timer
@echo It is %arg1% %HR% %AMPM%
Sleep 5
If %AMPM%==%Downtimeperiod% (goto exit) ELSE (@echo running next check)
If %HR% GEQ %DownTime% (goto exit) ELSE (@Echo gonna shutdown)
rem ********************************************************************
rem ***************checks to see if any clients are alive************************
:alive
del c:\temp\pingtest.txt
Del c:\temp\tick.txt
Ping 192.168.100.199 >> C:\temp\pingtest.txt
Ping 192.168.100.198 >> C:\temp\pingtest.txt
Ping 192.168.100.197 >> C:\temp\pingtest.txt
Ping 192.168.100.196 >> C:\temp\pingtest.txt
Find /c /i "TTL=" C:\temp\pingtest.txt > c:\temp\tick.txt
Rem (Shuts down your server if no active clients are found)
For /F "tokens=3 delims= " %%A in (c:\temp\tick.txt) do (
cls
if %%A LSS 2 goto choice
if %%A GTR 2 @echo System will stay awake.
)
Rem (If clients found wait five minutes and retest only if it's past 10pm else stays in standby)
sleep.exe 300
cls
goto alive
rem ******************provides choice to allow auto shutdown or not************
:choice
choice /T 60 /D Y /M "Is it ok for the system to shutdown"
IF ERRORLEVEL = 2 goto awake
IF ERRORLEVEL = 1 goto shutdown
goto exit
:shutdown
@echo system will shutdown after running drive logs.
rem **************run drive log based on day overwrites older logs*************
If not exist c:\temp\nul mkdir c:\temp
if not exist c:\temp\drv-logs\nul mkdir c:\temp\drv-logs
if not exist c:\temp\drv-logs\%arg1%\nul mkdir c:\temp\drv-logs\%arg1%
del /q c:\temp\drv-logs\%arg1%\*.txt
If exist A:\nul cmd /c "dir /s/b a:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-A.txt"
If exist B:\nul cmd /c "dir /s/b b:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-b.txt"
If exist c:\nul cmd /c "dir /s/b c:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-c.txt"
If exist d:\nul cmd /c "dir /s/b d:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-d.txt"
If exist e:\nul cmd /c "dir /s/b e:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-e.txt"
If exist f:\nul cmd /c "dir /s/b f:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-f.txt"
If exist g:\nul cmd /c "dir /s/b g:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-g.txt"
If exist h:\nul cmd /c "dir /s/b h:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-h.txt"
If exist i:\nul cmd /c "dir /s/b i:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-i.txt"
If exist j:\nul cmd /c "dir /s/b j:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-j.txt"
If exist k:\nul cmd /c "dir /s/b k:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-k.txt"
If exist l:\nul cmd /c "dir /s/b l:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-l.txt"
If exist m:\nul cmd /c "dir /s/b m:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-m.txt"
If exist n:\nul cmd /c "dir /s/b n:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-n.txt"
If exist o:\nul cmd /c "dir /s/b o:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-o.txt"
If exist p:\nul cmd /c "dir /s/b p:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-p.txt"
If exist q:\nul cmd /c "dir /s/b q:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-q.txt"
If exist r:\nul cmd /c "dir /s/b r:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-r.txt"
If exist s:\nul cmd /c "dir /s/b s:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-s.txt"
If exist t:\nul cmd /c "dir /s/b t:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-t.txt"
If exist u:\nul cmd /c "dir /s/b u:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-u.txt"
If exist v:\nul cmd /c "dir /s/b v:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-v.txt"
If exist w:\nul cmd /c "dir /s/b w:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-w.txt"
If exist x:\nul cmd /c "dir /s/b x:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-x.txt"
If exist y:\nul cmd /c "dir /s/b y:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-y.txt"
If exist z:\nul cmd /c "dir /s/b z:\ > c:\temp\drv-logs\%arg1%\%HR%%AMPM%-DRV-z.txt"
cls
choice /T 60 /D Y /M "Are you sure you want to shutdown?"
IF ERRORLEVEL = 2 goto awake
IF ERRORLEVEL = 1
shutdown.exe /F /P
goto exit
:awake
cls
@echo system will stay awake for 30min before testing again
sleep 1800
goto alive
:exit
************************************************************************
end script