Jump to content

Handling a hanging service


 Share

Recommended Posts

Hi, we have a homebrew app that our company has used for years, but now we need to uninstall the app from all of our machines. The app has a service that when I go to uninstall it hangs about 50% of the time. When the service hangs it sits in the stopping state. I've automated the uninstall, but obviously the script hangs waiting for the service to stop. The service is stoppable, but for whatever reason on 50% of the machines it fails to stop.

2 questions, how can I handle this scenario? I was thinking have a counter that keeps checking for the status of the service and after x amount of seconds if it's stuck in the stop pending state then cancel the uninstall. The only problem is that the script is hung up waiting for the WMI call to shut down the service. I guess this is where multi-threading comes in. I also thought about disabling the service and asking the user to reboot the machine, but we can't reboot these machines very often, so that's not an option. The second question, does anyone know how to forcefully shut down a hanging service? I've tried just about all the utilities and commands I can find like pskill, but none of them are working. Any advice you could give me would really help because this is high priority at my job right now. Thanks.

Edited by notta
Link to comment
Share on other sites

could you use functions like

WinWait()

WinWaitActive()

WinClose()

or similar? These functions can be used with a timeout setting, so if the window has not closed/opened etc., your script would continue. What your script then does can be determined using If...Then...Else and the @error return values of the functions. (0 or 1)

Hope that helps.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...