Processing
 

Windows Service not stopping in Windows Server 2012 but easily on Windows 7

14/09/2016 07:30#1

Joined at: 5 months ago

Post: 1

Thank: 0

Thanked: 0

I have a below script which is attached to a windows service on stop command:-

wmic service where name='%NS_SERVICE_NAME%' get ProcessId | more +1 > tmp.txt set /p NS_PID=<tmp.txt del tmp.txt for /f %%i in ('wmic process where "(ParentProcessId=%NS_PID%)" get ProcessId ^| more +1') do (     for /f %%a in ('wmic process where "(ParentProcessId=%%i)" get ProcessId ^| more +1') do (         echo %%a|findstr "^[-][1-9][0-9]*$ ^[1-9][0-9]*$ ^0$">nul && TASKKILL /F /PID %%a || rem         IF %ERRORLEVEL% NEQ 0 do (            exit         )     ) ) 

which works fine on Windows 7 and service stops quickly in 1-2 seconds, but in case of Windows Server 2012 the service does not stop and keeps in stopping state unless the process related to it is ended.

The error which I get in logs is as below:- "No Instance(s) Available."

Windows Service not stopping in Windows Server 2012 but easily on Windows 7

Similar articles

How to use Logstash with log4j in Windows 7 32-bit VM

5 months ago - Reply: 1 - Views: 136

Running webrick server in background for Windows

5 months ago - Reply: 0 - Views: 60

Task Scheduler doesn't start my exe for the next day

5 months ago - Reply: 0 - Views: 47

Unable to get Windows Updates in Windows 7 [on hold]

5 months ago - Reply: 0 - Views: 27

Connect Spark-Shell using Eclipse in Windows 7

5 months ago - Reply: 0 - Views: 28

Can't use custom windows themes

5 months ago - Reply: 1 - Views: 117

“npm install <module>” doesn't work

5 months ago - Reply: 0 - Views: 41

OpenGL 4.5 functions segfaulting

5 months ago - Reply: 0 - Views: 6

Executing a batch file during installation

5 months ago - Reply: 0 - Views: 3

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re