0

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
Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • "I decided to write like this.." OK. So, did you then try to apply that decision? What did you write so far? Why did it not work sufficiently for what you need? – underscore_d Nov 12 '19 at 12:28
  • is `windchill` running as a windows service? – Gerhard Nov 12 '19 at 13:01
  • @GerhardBarnard No. I just wrote some sample code here. Iam Fresher and new to this topic. so only. (path) windchill stop :: Also I have to set some buffer time for service stopping (path) windchill start for other services we can write like this right? – Dinesh venkatachalam Nov 12 '19 at 13:18

1 Answers1

0

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.

Gerhard
  • 22,678
  • 7
  • 27
  • 43
  • Also I should read the stdout of the windchill stop command and check if properly stopped or not.. I Think ">null 2&1" will suppress the stdout being displayed while the command is issued. Is there any solution? – Dinesh venkatachalam Nov 13 '19 at 05:09
  • No, the redirect here is for `timeout` only. Does it not have a `windchill status` option? If so it is possible to check that first before starting again. – Gerhard Nov 13 '19 at 06:01
  • yaa.. It has status option.. But how to check that? SC QUERY servicename | FIND “STATE” | FIND “STOPPED” .. will this work? – Dinesh venkatachalam Nov 13 '19 at 06:19
  • ok, send me what the status looks like when the services has been stopped, then I will update my answer. – Gerhard Nov 13 '19 at 06:24
  • I have updated the answer with the assumption that the status outputs `stopped` when running `windchill status` – Gerhard Nov 13 '19 at 06:32
  • I dont have access to windchil since iam a fresher. if possible kindly tell me for any windows service. after service is stopped i need to get that message and prints that message and then i have to start the service – Dinesh venkatachalam Nov 13 '19 at 06:50