Shutdown recognize, cancel and file start

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Heiti
Posts: 2
Joined: 03 Jan 2012 00:38

Shutdown recognize, cancel and file start

#1 Post by Heiti » 03 Jan 2012 00:46

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

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Shutdown recognize, cancel and file start

#2 Post by phillid » 03 Jan 2012 05:06

I'm not sure how to recognise a shutdown, but they can be cancelled by administrators using:

Code: Select all

shutdown -a


:) phillid

Heiti
Posts: 2
Joined: 03 Jan 2012 00:38

Re: Shutdown recognize, cancel and file start

#3 Post by Heiti » 04 Jan 2012 03:42

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

Post Reply