Q: I want to update an application using System Center Configuration Manager 2007—how do I ensure the application being updated isn’t running during the update?

Many application update programs automatically check if the application is running. If your application update doesn’t, you still have options.

John Savill

September 11, 2011

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A: Many application update programs automatically check if the application is running. If it is, they will stop the application, then perform the update, so no manual actions should be required. However, if your application update doesn’t perform this, you still have some options.

Firstly you could use SCCM to deploy the update only when no one is logged on, which would ensure the application is not running. Configure this through the Environment tab, where you would select the option Only when no user is logged on, which Figure 1 shows below:


Savill Fig1 System Center Config Mgr no user logged on

Another option would be to configure the actual SCCM advertisement to run either at logon or logoff which would again ensure the application isn’t running. Set this via the Schedule tab of the advertisement, and set a mandatory assignment that you can configure to Assign immediately after this event, which allows logon/logoff to be selected (see Figure 2 below).


Savill Fig2 System Center Config Manager logon/logoff

If your users never log off, you can write a custom script to check if the program is running. If it’s running, you can create a prompt to kill it or give users five minutes to finish up their work and close it themselves or it will be killed; then, at the end of the script, run the update exe or msi (using msiexec /i). This custom script would be specified as the SCCM program instead of the normal setup program. Below is a very short example that could be used as a foundation.

set objWMIService = GetObject ("winmgmts:")foundProc = FalseprocName = "winword.exe"procNameFriend = "Word"for each Process in objWMIService.InstancesOf ("Win32_Process")    If StrComp(Process.Name,procName,vbTextCompare) = 0 then        foundProc = True        procID = Process.ProcessId    End IfNextIf foundProc = True Then    WScript.Echo "Found Process (" & procID & ")"    UserConfirm = MsgBox("Process found, click OK to stop it or Cancel to wait 5 minutes",vbOKCancel+vbQuestion+vbSystemModal,"Stop " & procNameFriend & " Process")    If UserConfirm = vbOK then        WScript.Echo "Killing Process"        Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" &  procID)        For Each objProcess in colProcessList                objProcess.Terminate()        Next        WScript.Sleep(1000) 'wait for a second        Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" &  procID)        If colProcessList.count = 0 Then            WScript.Echo "Process killed"        End If    Else 'the user said to wait        WScript.Sleep(360000) 'wait for 5 minutes        WScript.Echo "Killing Process if not already stopped"        Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" &  procID)        For Each objProcess in colProcessList                objProcess.Terminate()        Next        WScript.Sleep(1000) 'wait for a second        Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" &  procID)        If colProcessList.count = 0 Then            WScript.Echo "Process not running"        End If    End If End If'perform the software installation in the next line'msiexec /i appinstall.msi


About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like