BOOT/Check Online Script

July 12, 2009 at 15:40:00
Specs: Windows XP\Server 2008
Hi Guys, I have a script to shutdown my file server remotely however I am looking for a way for it to check the computer has completed shutting down. Any ideas how this can be done

@ECHO OFF
echo %USERNAME% Shutdown on %date% - %time% >> \\Log\Shutdown.txt
ipconfig /all | find "IP Address" >> \\Log\Shutdown.txt
ipconfig /all | find "Host Name" >> \\Log\Shutdown.txt
"c:\Documents and Settings\%USERNAME%\Scripts\PsTools\"psexec \\192.168.1.1 -u Admin -i c:\windows\system32\shutdown.exe -s

Thanks


See More: BOOT/Check Online Script

Report •


#1
July 12, 2009 at 21:26:12
A ping -> errorlevel check should work assuming the server is pingable.


---

@ECHO OFF
echo %USERNAME% Shutdown on %date% - %time% >> \\Log\Shutdown.txt
ipconfig /all | find "IP Address" >> \\Log\Shutdown.txt
ipconfig /all | find "Host Name" >> \\Log\Shutdown.txt
"c:\Documents and Settings\%USERNAME%\Scripts\PsTools\"psexec \\192.168.1.1 -u Admin -i c:\windows\system32\shutdown.exe -s
:check
ping 192.168.1.1 -n 1 >nul
if %errorlevel% EQU 0 goto check
echo File Server successfully shutdown at %time% >> \\Log\Shutdown.txt


Report •

#2
July 13, 2009 at 03:44:16
Hi Thanks that worked great, I've also made a script to boot and map drive on server

@ECHO OFF
echo Checking if Server is awake
echo.

:alivecheck
ping 192.168.1.1 -n 2 >NUL
if %errorlevel% EQU 0 goto loginsys
if %errorlevel% EQU 1 goto bootsys
echo.

:bootsys
echo Booting Storage Server
"c:\Documents and Settings\%USERNAME%\Scripts\PsTools\"MC-WOL 00:11:41:d2:ec:1e >NUL
echo.
echo Checking system has booted.
echo.

:check
ping 192.168.1.1 -n 2 >NUL
if %errorlevel% EQU 0 goto check
echo.
echo System Boot successfull.
echo.

:loginsys
echo Logging into Server...
echo.
net use K: "\\Level" /user:Jon 
echo Log in successfull
echo.

echo %date% - %time% - %USERNAME% Logged on >> \\Log\Login.txt
ipconfig /all | find "IP Address" >> \\Log\Login.txt
ipconfig /all | find "Host Name" >> \\Log\Login.txt

Only problem I have is it trys to map drive as soon as it can ping any suggestions as to how i can make sure the system is fully booted before trying to map network drive

Thanks :)


Report •

#3
July 13, 2009 at 07:47:01
I haven't tested this - but checking for winlogon process with pslist should assure that the system has reached a point that will allow for drive mappings.

@ECHO OFF
echo Checking if Server is awake
echo.

:alivecheck
ping 192.168.1.1 -n 2 >NUL
if %errorlevel% EQU 0 goto loginsys
if %errorlevel% EQU 1 goto bootsys
echo.

:bootsys
echo Booting Storage Server
"c:\Documents and Settings\%USERNAME%\Scripts\PsTools\"MC-WOL 00:11:41:d2:ec:1e >NUL
echo.
echo Checking system has booted.
echo.

:check
ping 192.168.1.1 -n 2 >NUL
if %errorlevel% EQU 0 goto check
echo.
echo System Boot successfull.
echo.

:loginsys
echo Logging into Server...
echo.
"c:\Documents and Settings\%USERNAME%\Scripts\PsTools\pslist" \\192.168.1.1 Winlogon >NUL
if %errorlevel% EQU 0 GOTO loginshare
GOTO loginsys
:loginshare

net use K: "\\Level" /user:Jon
echo Log in successfull
echo.

echo %date% - %time% - %USERNAME% Logged on >> \\Log\Login.txt
ipconfig /all | find "IP Address" >> \\Log\Login.txt
ipconfig /all | find "Host Name" >> \\Log\Login.txt


Report •

Related Solutions

#4
July 13, 2009 at 10:07:37
Does work however require's admin rights on server to detect if winlogon is running...

Thanks


Report •

#5
July 14, 2009 at 08:48:10
We can try adding a loop that waits for the mapping to successfully complete, thoguh this is an endless loop if for some reason the server does not come up or doesn't map properly.

@ECHO OFF
echo Checking if Server is awake
echo.

:alivecheck
ping 192.168.1.1 -n 2 >NUL
if %errorlevel% EQU 0 goto loginsys
if %errorlevel% EQU 1 goto bootsys
echo.

:bootsys
echo Booting Storage Server
"c:\Documents and Settings\%USERNAME%\Scripts\PsTools\"MC-WOL 00:11:41:d2:ec:1e >NUL
echo.
echo Checking system has booted.
echo.

:check
ping 192.168.1.1 -n 2 >NUL
if %errorlevel% EQU 0 goto check
echo.
echo System Boot successful.
echo.

:loginsys
cls
echo Logging into Server...
echo.
net use K: "\\Level" /user:Jon
if %errorlevel% EQU 0 goto success
goto loginsys
:success
echo Log in successful

echo.

echo %date% - %time% - %USERNAME% Logged on >> \\Log\Login.txt
ipconfig /all | find "IP Address" >> \\Log\Login.txt
ipconfig /all | find "Host Name" >> \\Log\Login.txt


Report •


Ask Question