Page 1 of 1

Shutdown recognize, cancel and file start

Posted: 03 Jan 2012 00:46
by Heiti
Hello,

i want to ceat an batch file, which can recognize an shutdown. After this the batch file have to cancel the shutdown. At least the batch have to oben a Excel file.

I have no idea, how i can recognize an shutdown or how i can cancel a shutdown. Can somebody help me please.

Thx.

Greets Heiti

Re: Shutdown recognize, cancel and file start

Posted: 03 Jan 2012 05:06
by phillid
I'm not sure how to recognise a shutdown, but they can be cancelled by administrators using:

Code: Select all

shutdown -a


:) phillid

Re: Shutdown recognize, cancel and file start

Posted: 04 Jan 2012 03:42
by Heiti
Hey thx for your help. I try to do it with this Code:

Code: Select all

@echo off
:START
cls
REM -----Variablen erstellen
SET datum=%DATE%                     
SET datum_alt=
               
REM ----------------------------------

REM -----Variablen vorbelegen
REM -----Textdatei DB.txt öffnen, Zeile auslesen und das Datum in die Variable "datum_alt" schreiben
FOR /f %%f IN (DB.txt) DO @SET datum_alt=%%f

REM ----das aktuelle Datum in die Textdatei schreiben
ECHO %datum% >DB.txt

REM echo %datum%
REM echo %datum_alt%
REM echo %time%
REM ping 127.0.0.1 -n 10>nul
REM echo 10 sec später


REM -----Überprüfen ob der Rechner heute schon mal gestartet wurde.
IF %datum_alt% == %datum% GOTO :ENDE

REM -----Exel-Tabellestarten wenn der Rechner heute noch nicht hoch gefahren wurde
echo Stundenerfassung - Herunterfahren abgebrochen starten
%SystemRoot%\system32\shutdown.exe -a           
Stunden_2012.xls
GOTO :Absolut

:ENDE
echo Stundenerfassung nicht starten
echo %time%
ping 127.0.0.1 -n 5 > nul
echo 5 sec später
:Absolut


I open the batch file with an entry in the microsoft managment cosole.

Thank you all for your help.

Greets Heiti

P.S.: Sry about the German comments