Quite new to batch script, please help me out.

set Pathname="C:\S3Sync" 
cd %Pathname% 
S3Sync.exe -
timeout /t 10 
taskkill /im S3Sync.exe

I want to run the following process and if it stops or goes into an infinite time period, kill the process after 10 seconds and also use try and catch to get the error. what are the possibilities of using such statement?

有帮助吗?

解决方案

These commands may help you: Put them after the timeout command

set err=%errorlevel%
tasklist |find /i "s3sync.exe" >nul && taskkill /f /im S3Sync.exe

If your task hangs then the errorlevel will not be set correctly, of course.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top