Solved

Need sccm task to check for running process or install app

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

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

Suggested Solutions

Title # Comments Views Activity
sccm importing drivers 4 24
Admin account lockout 10 39
User account lockout - Server 2012R2 7 30
PDFCreator and PrimoPDF both fail to install 11 21
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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