Hi,
I'm still running media around my home with WHS(2003), it's fine for what we need and I don't see any reason to upgrade as its just for home (and I have spare Hardware). My UPS doesn't have have connectivity to the server, so I have no means of automatically shutting down the PC should there be a power failure. So I wrote a batch file to shutdown the server if connection was lost to the router (not on UPS) - by pinging router. all worked fine, until I had to reinstall after a Mobo failure. when I set the Batch File up again with the Scheduled task to run every 3 min it seems to run ok, except it doesn't shutdown the Server it just runs the command again? I have tried changing the command and it has the same result.
My Scheduled Task to run the command is set to repeat every 3 mins (i did have it to do it every 5 min), the batch file should shutdown the Server if it doesn't receive a reply from the router. the 2 scripts that I have tried are below:
Old Cmd - before re-install (used to work fine)
@Echo OFF
REM Ping switch/router
PING 192.168.0.1 | FINDSTR TTL
ECHO Errorlevel is %ERRORLEVEL%
REM Ping responds
IF %ERRORLEVEL% EQU 0 GOTO :ConnectedToLAN
REM Ping does not respond
IF %ERRORLEVEL% EQU 1 GOTO :NotConnectedToLAN
GOTO :eof
:ConnectedToLAN
ECHO Connected to LAN
GOTO :eof
:NotConnectedToLAN
ECHO Not connected to LAN
MKDIR %tmp%\TKH\Connected_to_Internet
REM VBScript to make popup dialog
(
ECHO.Option Explicit
ECHO.Dim oShell, retCode
ECHO.Set oShell = WScript.CreateObject^("WScript.Shell"^)
ECHO.retCode = oShell.Popup^("Shutdown computer now? If no answer is given within 90 sec computer will shutdown.", 90, "Shutdown?", 4 + 32^)
ECHO.Select Case retCode
ECHO. case 6, -1
ECHO. WScript.quit^(0^) 'Yes or time-out was chosen
ECHO. case 7
ECHO. WScript.quit^(1^) 'No was chosen
ECHO.End Select
)>"%tmp%\TKH\Connected_to_Internet\Shutdown.vbs"
CSCRIPT //nologo "%tmp%\TKH\Connected_to_Internet\Shutdown.vbs"
ECHO Errorlevel is %ERRORLEVEL%
REM Timeout or clicked Yes (Shutdown)
IF %ERRORLEVEL% EQU 0 SHUTDOWN /P /F
REM Clicked No (Do nothing)
IF %ERRORLEVEL% EQU 1 REM
REM Clean up
RD /Q /S "%tmp%\TKH\
New Cmd - tried because the cmd above didn't work
Ping 192.168.0.1
IF ERRORLEVEL 1 SHUTDOWN -s -f
My Server is a decrepit HP D530 CMT DG747A and any help would be most appreciated,
Best reagrds,
Ian