Search code examples
batch-fileptc-windchill

How to write a Batch file for Restarting Windchill with some Buffer time?


I need to Restart my windchill service. currently windchill stop and windchill start commands are using in windchill shell. I need to write batch file for this operation. After doing some research I decided to write like this..

NET STOP windchill stop
:: Also I have to set some buffer time for service stopping
NET START windchill start

Solution

  • If windchill is not running as a service:

    windchill stop && windchill start
    

    The conditional && will only allow execution of windchill start if windchill stop was successful. In other words, returns %errorlevel% of 1

    If you want to rely on a timeout, then use timeout and hope it does not take long.

    windchill stop
    :wait
    timeout /t 5 >nul 2>&1
    windchill status | find /I "stopped"
    if %errorlevel% equ 0 (
      windchill start
      goto :eof
    )
    goto :wait
    

    where above example times out for 10 seconds.