ESEGUIRE FILE *.BAT A INTERVALLI PRESTABILITI

mercoledì 11 giugno 2008 - 19.50

GT2431 Profilo | Newbie

SALVE SONO NUOVO SIA DELLA MATERIA CHE DEL FORUM, MA HO TANTA VOGLIA DI CAPIRE LA MATERIA E IMPARARE.
IL MIO PROBLEMA E CHE DURANTE IL GIORNO DALL'UFFICIO LANCIO PIU VOLTE UN ESEGUIBILE *.BAT CHE A SUA VOLTA ESEGUE UN APPLICATIVO CHE LEGGE UN FILE DI TESTO, PER POI MANDARE I DATI. MI SERVIREBBE AUTOMATIZZARE IL TUTTO.
TIPO CHE A INTERVALLI PRESTABILITI SI LEGGA IL FILE DI TESTO SE E MODIFICATO, LANCI IL FILE BAT.
SE AVETE ARGOMENTI O MANUALI DA LEGGERE O SUGGERIMENTI, SONO IN ATTESA. SALUTI.

fasol Profilo | Junior Member

usa le operazioni pianificate di windows il modo piu semplice e veloce....



meglio i perdenti xkè hanno la speranza di vincere...cosa che i vincenti nn hanno....

ridaria Profilo | Expert

se hai dimistichezza con vb6 puoi creare un eseguibile che avvii la mattina e chiudi la sera, ed in esso coi inserisci un contollo timer che ogni tot secondi verifica che ora è leggendo l'ora di sistema. Precedentemente hai inserito in una serie di variabili globali le ore prestabilite.

Il timer ogni volta legge l'ora di sistema, la confronta con quelle che hai inserito nelle variabili globali, e se l'ora coincide con una di queste allora ti lancia il file .bat.

Riccardo
Ridaria

Dainesi Profilo | Senior Member

>SALVE SONO NUOVO SIA DELLA MATERIA CHE DEL FORUM, MA HO TANTA
>VOGLIA DI CAPIRE LA MATERIA E IMPARARE.
>IL MIO PROBLEMA E CHE DURANTE IL GIORNO DALL'UFFICIO LANCIO PIU
>VOLTE UN ESEGUIBILE *.BAT CHE A SUA VOLTA ESEGUE UN APPLICATIVO
>CHE LEGGE UN FILE DI TESTO, PER POI MANDARE I DATI. MI SERVIREBBE
>AUTOMATIZZARE IL TUTTO.
>TIPO CHE A INTERVALLI PRESTABILITI SI LEGGA IL FILE DI TESTO
>SE E MODIFICATO, LANCI IL FILE BAT.
>SE AVETE ARGOMENTI O MANUALI DA LEGGERE O SUGGERIMENTI, SONO
>IN ATTESA. SALUTI.

Quando una volta lo schermo era nero e le lettere illuminavano parte dello schermo ... erano i tempi del pcp, del DOS, QBasic e GWBasic. Allora per i comuni mortali l'unico metodo economico per programmare erano i file batch.
Ora nessuno se li ricorda più.

Quando si dice "Nati con la camicia ..."

Rispolverando la memoria e spulciando in internet ho trovato questo esempio che fa al caso tuo.


@echo off :: This batch file allows you to run programs on certain days. :: Have this TODAY.BAT program CALLed from your AUTOEXEC.BAT. :: TODAY.BAT will read entries in a TODAY.INI file you must make. :: The entries in the TODAY.INI should look like this: :: 10-12-1999=DeleteOldDocs.bat :: 10-13-1999=Scandisk.bat :: 10-14-1999=PrintReports.bat :: Put the date into the DATE environment variable :: Response to DATE command should be like :: Current date is Sun 10-12-1997 :: Enter new date (mm-dd-yy): @echo.|date|find /i "current">#urrent.bat @echo set date=%%4>current.bat call #urrent.bat del ?urrent.bat :: Put the command for today into TODAYSCOMMAND variable :: Assumes existence of TODAY.INI in current directory find "%date%=" today.ini | sort /r | date | find "=" > en#er.bat @echo set todayscommand=%%5> enter.bat call en#er.bat del en?er.bat > nul :: Cleanup - delete DATE variable and INI entry (so it only runs once) type today.ini|find /v "%date%">today.ini set date= :: Run today's command call %todayscommand% set todayscommand= :: _____________________________________________________ :: If the command for the day requires user input, for :: example, you have to hit enter or answer yes or no, :: you should run a separate batch file instead of :: running the command directly. Assume you want to run :: CHKDSK with the /F option to fix errors. If it finds :: errors, it will ask you to type "y" or "n". You can :: create a batch file which will do this for you: :: ECHO Y|CHKDSK /F :: If all you need is to press "Enter", you can do this: :: ECHO.|CHKDSK /F :: If you need to press "y", AND THEN HIT "Enter", it :: gets more complicated. You have to create what is :: generally called a "script" containing the exact :: keystrokes you need to press. You can create it :: ahead of time, or as needed like this: :: ECHO Y>SCRIPT.TXT :: ECHO.>>SCRIPT.TXT :: TYPE SCRIPT.TXT|CHKDSK /F :: Notice the first line had only one ">", but the :: second line had two ">>". Just one will cause :: the SCRIPT.TXT to be created new (if it already :: exists, it will be erased to start over fresh). :: The two >> will cause things to be appended to :: the existing SCRIPT.TXT

Dainesi Profilo | Senior Member

Come ho detto in un precedente messaggio, ho riportato uno stralcio di soluzione in batch file ma sono un pò arrugginito in materia (e quindi non vado oltre ai commenti riportati nel codice). Restando invece in ambito del forum, puoi sempre scriverti un "servizio NT" che a intervalli prestabiliti esegua i tuoi task.

Per scrivere un servizio NT con VB6 leggi quanto trovi qui http://montgomerysoftware.com/CreatingNTServiceInVB.aspx.
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5