Check for running processes before deploying

3

Hi everyone,

i am fairly new to Deploy and Inventory and we bought Deploy and Inventory mainly to help us deploy software to our Remote Desktop Servers. Deploying software is working greate, using commands i am able to change user state to install and execute. Now i am wondering, is there an option to check with inventory or deploy if there are currently users connected to those servers or if they are currently using the software i want to update? I'm a little concernt about problems and corrupted installations while trying to update a software that is currently in use by users. Our users tend to stay logged on all night or work in the middle of night so there is never a real window where i can be sure that no one is logged on.

Greetings

Freddy

Cancel
login to comment
3

Oh nice! I've been using PowerShell myself:

$Processes = Get-Process
if ( $Processes.ProcessName -contains "chrome" ) {
    Write-Output "Process Found - stopping"
    Exit 22
} Else {
    Write-Output "Process Not Found"
    Exit 11
}

Stop Process if Found

Does this work? I tried something similar to detect it a specific service exists but can't get it to work. I'm using: if (get-service "Tenable Nessus Agent" -ErrorAction SilentlyContinue) { exit 33 } else { exit 44 }

I have 33 in the Success Codes box and I have the task set to "Stop deployment with Success". Problem is if I type gibberish in the Service name, it still stops and says success.

If I replace the Exit parts with writing Yes or No to the screen, that seems to work fine. I'm brand new to the PDQ software so I might be doing something wrong. I simply want a way that I can check for a specific file or service before deploying something to check and see if it already exists or not.

Hey there, my example should work you just need to use Get-Service, and use the DisplayName for the property in the If statement.

However, in your example, I believe you may have the logic of stop with success backwards. You've told the package that, a code 33 is successful, and to continue onward with the package steps. Which means if the step returns anything other than 0 or 33, to stop the package and mark it as successful.

When you type in the gibberish service you are probably receiving 44 as a return which is not considered a success code, so the step "fails with success" then stops the package and reports a successful deployment.

When using Stop deployment with Success, you want the package to stop on that step if a condition in your script is met and you exit with the "fail with success" code you define (22 in my example) and if the condition is not met, to continue onward with the with your defined success code.

Cancel
login to comment

4

To check if a process is running I use this code, in this case when javaw.exe is running the deployement stops

%WINDIR%\System32\tasklist /FI "IMAGENAME eq javaw.exe" | find /I /N "javaw.exe"

also change the Succes codes field to "1"

enter image description here

Cancel
login to comment

1

You ever tried to generealize this? I am currently trying to put this script in a package, instead copy and past this script and creating several different versions of it. One script with the process name as a variable, no problem, but how to set something like a package wide variable or passing variables to packages. I am currently using nexted packages to update our RDS Servers. Step1 change user state, Step 2 install/update .... It would be cool to put this like a preflightcheck in front of all other steps but without creating this script for every single nested package.

Cancel
login to comment

0

Looks interessting too, i will try this method too, since i am personal a fan of powershell.

Cancel
login to comment

0

Works great thank you !

Cancel
login to comment

Reply