Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need sccm task to check for running process or install app

Posted on 2014-09-14
3
Medium Priority
?
1,271 Views
Last Modified: 2014-09-30
I have to setup a task to run if a particular application or process is installed.  Is it possible to configure a task to check for a process or install application? Is so, how is it done?
0
Comment
Question by:rdefino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Expert Comment

by:cantoris
ID: 40322719
I do this sort of thing with a bit of VBScript.
The package launches the script which uses WMI to check for the running process and from there makes the decision whether or not to do the next thing.

For a more complex example, I've done packages where an app needs to be upgraded but the user might be running it.  If it's not running, the script does the upgrade by calling the executable and passing silent parameters.  If the task is already running then it alerts the user, asking them to close the app at their convenience.  It then rechecks every ten seconds to see if it can run the upgrade and then afterwards tells the user all is OK.  I also did one that would remind the user every ten minutes if they ignored the request.
Of course there's always at least one user who closes the app and then shuts down, breaking the scripts flow - unless you have a re-run package on failure set to try again on next boot.
0
 

Author Comment

by:rdefino
ID: 40323324
How would I do it a vb script in sccm 2012?
0
 
LVL 16

Accepted Solution

by:
cantoris earned 2000 total points
ID: 40323388
I don't have practical experience of SCCM 2012.

My more complex examples of VBScript for this sort of thing have used a couple of hundreds of lines of code to include full error-trapping and return codes etc.

For example, here's my function for checking if a process is running.  It returns True or False for if the named process is active or 666 if the WMI call failed!  The first three lines are defined elsewhere outside the function.
Const WBEMFLAGRETURNWHENCOMPLETE = 0
Const DEADWMI = 666
Set objSWbemServices = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

Function fnIsRunning(ByVal strProcessName)
 ' Is the specified process running?  Returns boolean.
	On Error Resume Next
	strWQLQuery = "SELECT Name FROM Win32_Process WHERE Name='" & LCase(strProcessName) & "'"
	Set colProcesses = objSWbemServices.ExecQuery(strWQLQuery,, WBEMFLAGRETURNWHENCOMPLETE)
	If Err.Number = 0 Then
		fnIsRunning = (colProcesses.Count > 0)
	Else
		fnIsRunning = DEADWMI
	End If
End Function

Open in new window

0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question