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
Solved

Need sccm task to check for running process or install app

Posted on 2014-09-14
3
1,048 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

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This article describes my battle tested process for setting up delegation. I use this process anywhere that I need to setup delegation. In the article I will show how it applies to Active Directory
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

809 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