Perform all the SCCM Client Actions

image_pdfimage_print

This script performs all the actions as mentioned in the SCCM Client.

SCCM 2007 Client Actions
The benefit is that you do not have to initiate each client action manually, the script takes care of it. SCCM Client Center is 32 bits, so on a 64 bit OS the wscript in %windir%\SysWOW64 is used.

If run on a Windows 8 x86 the output looks like:

SCCM Client Actions output VBS

There are two versions: one for SCCM 2007 and earlier and one for SCCM 2012. The SCCM 2007 version uses the 32 bits wscript engine, also on 64 bits machines.

The code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
' ================================================================================================
' Performs all the SCCM Client Actions
' Created by Willem-Jan Vroom
' 
' 0.0.1
'    Initial version
'
'
' ================================================================================================
 
' ------------------------------------------------------------------------------------------------
' Declare the most variables. 
' ------------------------------------------------------------------------------------------------
 
  Option Explicit
 
  Dim objFSO          : Set objFSO         = WScript.CreateObject("Scripting.FileSystemObject")
  Dim objShell        : Set objShell       = CreateObject("Wscript.Shell")
  Dim objCPAppletMgr  :
  Dim strWindir       : strWinDir          = objShell.ExpandEnvironmentStrings("%WinDir%")
  Dim Counter         : Counter            = 1
  Dim strText         : strText            = ""
  Dim strArchitecture : strArchitecture    = "x86"
  Dim strCommand      : strCommand         = ""
  Dim arrClientActions
  Dim objClientAction
 
' ------------------------------------------------------------------------------------------------
' Detect the current OS architecture.  
' ------------------------------------------------------------------------------------------------
 
  if objFSO.FolderExists(strWindir & "\syswow64") Then
     strArchitecture = "x64"
  end if
 
' ------------------------------------------------------------------------------------------------
' If run on a x64 OS run this script again but then with the 32 bits wscript.exe.
' SCCM Client is 32 bit only.
' ------------------------------------------------------------------------------------------------
 
  if strArchitecture = "x64" and instr(lcase(wscript.FullName),"system32") > 0 Then
     strCommand = strWinDir & "\syswow64\wscript.exe " & chr(34) & wscript.scriptfullname & chr(34)
     result = objShell.Run (strCommand,0,True)
     wscript.quit (result)
  end if
 
' ------------------------------------------------------------------------------------------------
' Perform all the SCCM Client Actions
' ------------------------------------------------------------------------------------------------
 
  On Error Resume Next
 
  Set objCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")
  If Err.Number <> 0 Then
     msgbox "There is no SCCM Client installed on this system.",16,"SCCM Client Actions -- FAILED --"
     wscript.quit
  End if
 
  On Error Goto 0
 
' ------------------------------------------------------------------------------------------------
' Display the results
' ------------------------------------------------------------------------------------------------
 
  Set arrClientActions = objCPAppletMgr.GetClientActions()
  For Each objClientAction In arrClientActions
      objClientAction.PerformAction
      strText = strText & " -- Action: '" & objClientAction.Name & "' has been initiated successfully. " & vbCrLf
  Next
  strText = strText & vbcrlf & "Script engine: " & wscript.FullName & vbcrlf
  msgbox strText,64,"SCCM Client Actions"
 
' ================================================================================================
' END SCRIPT
' ================================================================================================

And the version for SCCM 2012:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
' ================================================================================================
' Performs all the SCCM Client Actions
' Created by Willem-Jan Vroom
' 
' 0.0.1
'    Initial version
'
'
' ================================================================================================
 
' ------------------------------------------------------------------------------------------------
' Declare the most variables. 
' ------------------------------------------------------------------------------------------------
 
  Option Explicit
 
  Dim objFSO          : Set objFSO         = WScript.CreateObject("Scripting.FileSystemObject")
  Dim objShell        : Set objShell       = CreateObject("Wscript.Shell")
  Dim objCPAppletMgr  :
  Dim strWindir       : strWinDir          = objShell.ExpandEnvironmentStrings("%WinDir%")
  Dim Counter         : Counter            = 1
  Dim strText         : strText            = ""
  Dim strArchitecture : strArchitecture    = "x86"
  Dim strCommand      : strCommand         = ""
  Dim arrClientActions
  Dim objClientAction
 
' ------------------------------------------------------------------------------------------------
' Detect the current OS architecture.  
' ------------------------------------------------------------------------------------------------
 
  if objFSO.FolderExists(strWindir & "\syswow64") Then
     strArchitecture = "x64"
  end if
 
' ------------------------------------------------------------------------------------------------
' Perform all the SCCM Client Actions
' ------------------------------------------------------------------------------------------------
 
  On Error Resume Next
 
  Set objCPAppletMgr = CreateObject("CPApplet.CPAppletMgr")
  If Err.Number <> 0 Then
     msgbox "There is no SCCM Client installed on this system.",16,"SCCM Client Actions -- FAILED --"
     wscript.quit
  End if
 
  On Error Goto 0
 
' ------------------------------------------------------------------------------------------------
' Display the results
' ------------------------------------------------------------------------------------------------
 
  Set arrClientActions = objCPAppletMgr.GetClientActions()
  For Each objClientAction In arrClientActions
      objClientAction.PerformAction
      strText = strText & " -- Action: '" & objClientAction.Name & "' has been initiated successfully. " & vbCrLf
  Next
  strText = strText & vbcrlf & "Script engine: " & wscript.FullName & vbcrlf
  msgbox strText,64,"SCCM Client Actions"
 
' ================================================================================================
' END SCRIPT
' ================================================================================================

Permanent link to this article: https://www.vroom.cc/wordpress/perform-all-the-sccm-2007-client-actions/