I was recently troubleshooting a problem with the Install Client wizard in the admin console which will be documented in the KB shortly. To workaround
the issue I created a script that uses the same WMI methods (CreateCCRs and CreateCCR) that this wizard uses. This exact script may not be applicable to
everyone but it does demonstrate how to use the CreateCCR and CreateCCRs methods.
To install the script simply execute the vbs on your SMS Admin console box, then launch the script through the admin console - queries node.
'Rslaten 06/01/2006
'VBScript to add a new node to the SMS Admin Console\Queries\ called SMS_Tools\Install Clients
'Once ran from the Admin Console it uses the CreateCCRs WMI method on the SMS_Query instance to create CCRs
'Update: This VBScript now adds a menu to push a CCR for a single client (result of the query)
'This uses the SMS_Collection::CreateCCR method with the same parameters
'The CCRs created have the following parameters:
'SMS_Query::CreateCCRs method parameters
'PushOnlyAssignedClients = FALSE
'ClientType = 1
'Forced = TRUE
'PushEvenIfDC = FALSE
'InformationOnly = FALSE
'SMS_Collection::CreateCCR method parameters
'ResourceID =
'PushOnlyAssignedClients = FALSE
'ClientType = 1
'Forced = TRUE
'PushEvenIfDC = FALSE
'InformationOnly = FALSE
Main
Sub Main
On Error Resume Next
'Check to see if any parameters were passed
If WScript.Arguments.Count = 0 Then
'This is being run by a user so create regkeys and copy script to admin console directory
InstallScript
WScript.Quit
Else
'This is being run from the admin console so continue with CCR creation
CreateCCRs
End If
End Sub
'Install routine (only runs if no parameters are passed to script)
Sub InstallScript
On Error Resume Next
Dim oShell, sUIPath, oFso, sCurrentDirectory
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
'Get directory of SMS Admin Console
sUIPath = oShell.RegRead("HKLM\SOFTWARE\Microsoft\SMS\Setup\UI Installation Directory")
If Err.number <> 0 Then
WScript.Echo "Failed to get Admin Console Installation Directory from registry"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
'Get current directory
sCurrentDirectory = oShell.CurrentDirectory
If Err.number <> 0 Then
WScript.Echo "Failed to get current directory"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
'Create registry key for MMC snapin
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{58105356-2B9C-11D1-B0D5-00C04FBBD480}" _
& "\Extensions\SMS_Tools\ForceInstallClient\CommandLine", "wscript.exe " & sUIPath & "\ClientInstall.vbs " _
& "##SUB:__SERVER## ##SUB:__NAMESPACE## ##SUB:QueryID##"
If Err.number <> 0 Then
WScript.Echo "Failed to create MMC snap-in regkey and CommandLine value"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{58105356-2B9C-11D1-B0D5-00C04FBBD480}" _
& "\Extensions\SMS_Tools\ForceInstallClient\Description", "Install Client"
If Err.number <> 0 Then
WScript.Echo "Failed to create Description regvalue"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{58105356-2B9C-11D1-B0D5-00C04FBBD480}" _
& "\Extensions\SMS_Tools\ForceInstallClient\Name", "Install Clients"
If Err.number <> 0 Then
WScript.Echo "Failed to create Name regvalue"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{4D26C0D4-A8A8-11D1-9BD9-00C04FBBD480}" _
& "\Extensions\SMS_Tools\ForceInstallClient\CommandLine", "wscript.exe " & sUIPath _
& "\ClientInstall.vbs ##SUB:__SERVER## ##SUB:__NAMESPACE## ##SUB:ResourceID##"
If Err.number <> 0 Then
WScript.Echo "Failed to create MMC snap-in regkey and CommandLine value"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{4D26C0D4-A8A8-11D1-9BD9-00C04FBBD480}" _
& "\Extensions\SMS_Tools\ForceInstallClient\Description", "Install Client"
If Err.number <> 0 Then
WScript.Echo "Failed to create Description regvalue"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
oShell.RegWrite "HKLM\SOFTWARE\Microsoft\MMC\NodeTypes\{4D26C0D4-A8A8-11D1-9BD9-00C04FBBD480}" _
& "\Extensions\SMS_Tools\ForceInstallClient\Name", "Install Client"
If Err.number <> 0 Then
WScript.Echo "Failed to create Name regvalue"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
'Copy this script to the SMS Admin Console directory
oFSO.CopyFile WScript.ScriptFullName, sUIPath & "\ClientInstall.vbs"
If Err.number <> 0 Then
WScript.Echo "Failed to copy " & sCurrentDirectory & "\ClientInstall.vbs to " & sUIPath & "\"
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
WScript.Echo "Successfully Installed ClientInstall.vbs onto your SMS Admin Console!"
'Clean up objects
Set oFSO = Nothing
Set oShell = Nothing
End Sub
'Create CCR routine (only runs if being ran from admin console)
Sub CreateCCRs
On Error Resume Next
Dim oWMI, sSMSNamespace, sSMSServer, sQueryID, sResourceID, sTempArg
'Go through parameters passed by script
Set objArgs = WScript.Arguments
sTempArg = objArgs(2)
If IsNumeric(sTempArg) = FALSE Then
sSMSServer = objArgs(0)
sSMSNamespace = objArgs(1)
sQueryID = objArgs(2)
'Connect to WMI
Set oWMI = GetObject("winMgmts:\\" & sSMSServer & "\" & sSMSNamespace & ":SMS_Query.QueryID='" _
& sQueryID & "'")
If Err.number <> 0 Then
WScript.Echo "Failed to connect to WMI on " & sSMSServer
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
'Run CreateCCRs Method
oWMI.CreateCCRs FALSE, 1, TRUE, FALSE, FALSE
If Err.number <> 0 Then
WScript.Echo "Failed to run CreateCCRs method on " & sSMSServer
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
WScript.Echo "Client Install Request(s) Sent Successfully!"
Else
sSMSServer = objArgs(0)
sSMSNamespace = objArgs(1)
sResourceID = objArgs(2)
'Check to see if we fail to get the 3rd parameter (if so this is an issue with the SMS Admin Console)
If Err.number <> 0 or sResourceID = "" Then
sResourceID = InputBox("Please Enter the Resource ID of this Client", "Client Install")
If sResourceID = "" or IsNumeric(sResourceID) = FALSE Then
WScript.Echo "Invalid Resource ID!"
WScript.Quit
End If
End If
'Reset Err object
Err.number = 0
'Connect to WMI
Set oWMI = GetObject("winMgmts:\\" & sSMSServer & "\" & sSMSNamespace & ":SMS_Collection")
If Err.number <> 0 Then
WScript.Echo "Failed to connect to WMI on " & sSMSServer
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
'Run CreateCCR Method
oWMI.CreateCCR sResourceID, FALSE, 1, TRUE, FALSE, FALSE
If Err.number <> 0 Then
WScript.Echo "Failed to run CreateCCR method on " & sSMSServer
WScript.Echo "Error = " & Err.number & " - " & Err.Description
WScript.Quit
End If
WScript.Echo "Client Install Request Sent Successfully!"
End If
'Clean up objects
Set oWMI = Nothing
End Sub