Solved

Need sccm task to check for running process or install app

Posted on 2014-09-14
3
947 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
  • 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 500 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

Join & Write a Comment

This is a fairly complicated script that will install the required prerequisites to install SCCM 2012 R2 on a server.  It was designed under the functional model in order to compartmentalize each step required, reducing the overall complexity.  The …
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now