Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Process running condition and workaround script suggestions

I love the new File and Registry Exists/Does Not Exist conditions. If I can make a suggestion, I think a process running/not running condition would be very useful as well as a feature request.

Since we don't have this feature yet, I thought I'd share some scripts I'm using to work around this:

BAT to check for running process - fails (exit code 7) if running, passes if not (exit code 6):

@echo off
SETLOCAL EnableExtensions
set EXE=TeamViewer.exe
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND
goto FIN

Additional mods to step: Must add 6 as a success code. Otherwise, just change line 6 to "EXIT /B 0"


When I'm deploying Java, the above code isn't as useful, since there's a good chance someone will almost always be running either java.exe, iexplore.exe, and/or firefox.exe. So I found the following VBScript to prompt the user to consent to the update before it starts:

Set objShell = CreateObject("Wscript.Shell")
intReturn = objShell.Popup("Do you want to update java? All instances of IE and Firefox will be closed. Please save your work before clicking Yes. To cancel, click No.", 86400, "Update Java", 4 + 32)
If intReturn = 6 Then
ElseIf intReturn = 7 Then
End If

Additional mods to step:

  1. Has to be an Install step pointed to the vbs file.
  2. Again, requires success code 6 be added.
  3. Custom command line has to be changed to cscript.exe //i "PromptToInstallJava.vbs" so that the user can see the prompt.
  4. Logged on State should be Only run if a user is logged on so you don't unnecessarily delay your deployment.
  5. Run As should be changed to Logged on User.
  6. I also set a custom timeout of 2160 minutes for the entire package so the user would have 24 hours to click Yes if they weren't able to run it right away.

Hope this helps someone else that wants to deploy with as little disruption as possible to the users!



1 comment
Date Votes
  • I ran into a similar problem today. I wanted to run the uninstaller for Dymo LabelMaker in one step, and then run the installer for the new version in a later step. My problem was that the uninstaller process returns immediately after spawning a second process to actually do the removal. Here's a short PowerShell step I placed between the two. It waits up to 5 minutes for that spawned process to terminate before moving on to the installation phase. I'll probably reuse it in future packages.

    # This step should take a maximum of 5 minutes
    $now = date;
    $maxWait = $now.AddMinutes(5);

    $process = get-process -Name "Au_";
    #We’ll say there’s nothing notable if the process isn’t running to begin with.
    if ($process -eq $null) {exit 0;}

    $uninstallComplete = $false;

    while ($maxWait -gt $now) {
        $uninstallComplete = $process.WaitForExit(1000);
        if ($uninstallComplete) {break}
        $now = date;

    # 1460: ERROR_TIMEOUT - This operation returned because the timeout period expired.
    if (-not $uninstallComplete) {exit 1460;}
    exit 0;