Solved

Need sccm task to check for running process or install app

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

632 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