Jump to content

Taskkilling ends up with an error, WPI going too fast? - Solution here


Recommended Posts

Some apps, for example, open up the freshly installed application after installing. Now everybody propably knows that this can be solved with taskkill by using a .bat. But it doesn't always work out - WPI goes to execute the .bat with all the taskkill commands TOO EARLY, like just a millisecond after the installer tells WPI "I'm finished" - and taskkilling ends up with an error because the app that was supposed to be killed hasn't yet started. Now the simple solution is telling the WPI to wait some seconds before executing the next command (the command that tells to execute the .bat with taskkill commands), so the app that the installer opens up (the one you are going to taskkill), has enough time to actually open.

What some people might have tried is %sleep%. Now here's the problem, it doesn't work. The WPI changelog tells us to use %sleep% while the command is actually {SLEEP}. I suggest that you fix the changelog because %sleep% really doesn't work. I created this topic to inform people about this wrong command that WPI changelog tells you to use - and also give you the idea of how this problem of taskkilling ending up with an error can simply be solved. In conclusion, here's the instructions:

Line 1. Command is the installer command with silent switches that you normally use. The installer opens the freshly installed app after the instalation has succeeded.

Line 2. Use command {SLEEP} 5 to tell WPI to wait 5 seconds before rushing into executing the next command, command three. During these 5 seconds, the freshly just-installed app has enough time to actually launch its process .exe so the next command doesn't end up failing.

Line 3. Use the command you normally use to execute the .bat file that has the taskkill command(s). Now that the app had 5 seconds time to launch, taskkilling should end up ok without an error

You can use whatever number in place of 5. 5 is actually quite a lot. Usually 2 or 3 is enough time for any app to start its process. 1 is propably not enough.

I hope this helps you people.

Link to comment
Share on other sites

You can use AutoIT with WinWait to wait for the window to appear rather than relying on an not always reliable sleep command. You can also use WinClose to send the close message to the window, ControlClick to click the various confirm close buttons the application may show (use the Window Info tool to get the codes for those) and WinWaitClose to have the autoit script wait until the window has actually closed.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.

  • Create New...