"Markus Wetzel" <> said this in news item
news:hj2135$9bj$...
> Am 18.01.2010 13:47, schrieb Pegasus [MVP]:
>>
>> Let's have a look at your script!
>
> No problem:
>
> @echo off
> sleep 300
> echo "OpenVPN Service beenden"
> net stop "OpenVPN Service"
> sleep 10
> echo "OpenVPN Service starten"
> net start "OpenVPN Service"
>
> I have to correct myself: The script is in the directory C:\Programme
> (German windows) and is called "OpenVPN restart.bat"
>
> It works great when I start it by clicking on it. (For testing purposes
> with sleep 5. Could the sleep 300 command be a problem? Maybe script
> timeout or something like that?)
When you want your batch files to be robust then you must fully qualify all
executables that are not native to Windows. Sleep.exe is not native to
Windows and it could be stored anywhere on your disk. You can actually
replace it with ping.exe, which is a native Windows program. You should also
add some diagnostics to your batch file so that you can see what's going on.
Try this version:
@echo off
echo Batchdatei gestartet am %date% um %time:~0, 5% >> c:\test.txt
ping localhost -n 300 > nul
echo "OpenVPN Service beenden" >> c:\test.txt
net stop "OpenVPN Service" 1>> c:\test.txt 2>>&1
echo 10 Sekunden warten >> c:\test.txt
ping localhost -n 10 > nul
echo "OpenVPN Service starten" >> c:\test.txt
net start "OpenVPN Service" 1>> c:\test.txt 2>>&1
echo Batchdatei beendet um %time:~0, 5% >> c:\test.txt
echo\ >> c:\test.txt
If the batch file still fails to run then you can examine the full runtime
details in c:\test.txt.
|