Come creare Timestamps in file batch

July 3

Come creare Timestamps in file batch


È possibile creare e utilizzare i file batch per automatizzare diverse attività di amministrazione del sistema, come ad esempio i backup, programmi e aggiornamenti del database o errori di registrazione, quando si verificano un problemi applicativi. i comandi DOS che vengono utilizzati nei file batch può includere una variabile, come la data e l'ora. Utilizzando la stringa dell'uscita dalla data e ora i comandi DOS è possibile creare timestamp nei file batch per registrare informazioni in tempo durante l'esecuzione delle procedure di manutenzione del sistema.

istruzione

1 Fare clic su "Start", "Blocco note" per aprire programma di editing Blocco note.

2 Fare clic su "File", "Nuovo".

3 Immettere i seguenti comandi nella finestra aperta:

@echo off

cls

rem Timestamp Generator

rem Analizzare la data (ad esempio, Ven 02/08/2008)

set cur_yyyy = Data%: ~ 10,4%

set cur_mm = Data%: ~ 4,2%

set cur_dd = Data%: ~ 7,2%

rem analizzare il tempo (ad esempio, 11: 17: 13.49)

set cur_hh = tempo%: ~ 0,2%

se% cur_hh% LSS 10 (tempo impostato cur_hh = 0%: ~ 1,1%)

set cur_nn = tempo%: ~ 3,2%

set cur_ss = tempo%: ~ 6,2%

set cur_ms = tempo%: ~ 9,2%

rem Impostare il formato di data e ora

set timestamp =% cur_yyyy %% %% cur_mm cur_dd% -% cur_hh %% %% cur_nn

cur_ss %% cur_ms%

rem Do something with it

eco timestamp:% timestamp%

rem Cancella le variabili d'ambiente

set cur_yyyy =

set cur_mm =

set cur_dd =

set cur_hh =

set cur_nn =

set cur_ss =

set cur_ms =

set timestamp =

4 Fare clic su "File", "Salva". Inserire "mybatchfile.bat" nel "Salva con nome" scatola. Fai clic su "OK" per creare il file batch con timestamp.