/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Kace script verify two or more process are not running

06/01/2017 711 views
Hello, i have created a online kscript that verifies if a process is running if so (on success)run something.
Now i want to add two or more processes to the same script. So the outcome will be all both or three processes are no running then on success run something.
However i tried adding two more verify a process is running to the same task. this has not worked as it looks like it will only continue if there is a success.
for example
process 1 = is running
Process 2 = is running
process 3 = is running.

The output is it checks process 1 and thats a fail as it is running, then it does not check process 2 or 3.

I tried adding different tasks so that it verifies each process, but the output im looking for is i only want something to run if all three processes are not running.

Any ideas on this?

thanks

2 Comments   [ + ] Show comments

Comments

  • You could do this with a powershell script. your list of processes and then count them. If all are closed, Succeed, otherwise it will fail. Make sure to adjust your process names and the -eq # to what you need

    Just do a launch program:
    Dir:$(KACE_SYS_DIR)
    File:Powershell.exe
    Wait
    executionpolicy bypass -file "$(KACE_DEPENDENCY_DIR)\ProcCheck.ps1"

    Then save this as ProcCheck.ps1

    $Output = 0
    @(
    "Word",
    "Outlook",
    "Excel"
    ) | Foreach-Object {
    if (Get-Process $_ -ErrorAction SilentlyContinue)
    { Write-Output "$_ is running" }
    else {
    Write-Output "$_ is not running... Adding 1 to variable"
    $Output++ }
    }
    Write-Host $Output
    If (($Output) -eq 3) { Exit 0 } else { Exit 1 }
  • Many Thanks i was just thinking after i wrote this that maybe i should use a online shell script as its for macOS. Thanks again

All Answers

0
Another way to do it would be to check for each process and kill it if it is running. If that will interfere with users then you could create a message window that advises them to close whatever programs before the script begins.
Answered 06/06/2017 by: JasonEgg
Red Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ