System Center 2012 ConfigMgr: Using VBS to Extend the DCM Script Execution Timeout Value

In System Center 2012 Configuration Manager, if you want to extend the execution timeout value(the default value is 60sec ) of the client to run the long time cusotmized script(such as file/user saerching) in your Configuration Item, then you can try to run following script for your site server to modify the site control setting, and make your client to refresh the policy to get the new timeout value.

Steps:

0: Specify the new timeout value in script:

e.g.(set new value as 10mins): NewValue = 600

1: Save the script in a vbs file.

e.g.: test.vbs

2: Run the script by sepcify the site server and site code in a correct credential which has the permission the make the change on your site server.

e.g.: c:\cscript.exe test.vbs MySite PRS 

3: After it modified the value successfully, you can triger a machine policy retrieval and evaluation cycle for your client, then your client would download the latest policy and the value should be changed. To verify the new value applied on client, you can run wbemtest, and connect to the namespace "root\ccm\policy\machine\actualconfig" then run query: "Select ScriptExecutionTimeout from CCM_ConfigurationManagementClientConfig" to see if value has been changed.

-Script Body-

On Error Resume Next

' Define string variables

Class_Name = "SMS_SCI_ClientComp"
Class_ItemName = "Configuration Management Agent"
Class_ItemType = "Client Component"
Property_Name = "ScriptExecutionTimeout"
NewValue = 600

' Check command line parameters ?on failure, report the error and terminate.
' The SMS Provider server name and the site code are required.

set args=wscript.arguments

If args.Count = 2 then
    SMSProviderServer = UCASE(Wscript.Arguments(0))
    SiteCode = UCASE(Wscript.Arguments(1))
Else
    wscript.Echo "Incorrect command line arguments." & vbCrLf & "Usage: cscript /nologo ModifySCFProperty.vbs <smsproviderserver> <sitecode>" & vbCrLf & "Example: cscript /nologo ModifySCFProperty.vbs SERVER1 S01" & vbCrLf
    WScript.Quit(1)
End If

' Connect to the SMS Provider ?on failure, report the error and exit.

SMSProviderServer = "\\" + SMSProviderServer + "\"
Set ObjSvc = GetObject("winmgmts:" & "{impersonationLevel=Impersonate,authenticationLevel=Pkt}!" & SMSProviderServer & "root\sms\site_" & SiteCode)

If Err.Number <> 0 Then
    wscript.Echo "Failed to connect to provider server with code: " & Err.Number & ". Exiting!"
    WScript.Quit(2)
End If

' Get the requested instance of the class ?on failure, report the error and exit.

Set objInst = ObjSvc.Get(Class_Name & ".ItemName='" & Class_ItemName & "',ItemType='" & Class_ItemType & "',SiteCode='" & SiteCode &"'")

If Err.Number <> 0 Then
    WScript.Echo "Failed to open desired object with error code " & Err.Number & " (" & Err.Description & "). Exiting!"
    WScript.Quit(3)
End If

' Loop through the properties until we find a match (or run out of properties) ?on failure, report the error and exit.

bFoundProperty = False

For Each objProp in objInst.Props
    If objProp.PropertyName = Property_Name Then
        bFoundProperty = True
        Exit For
    End If
Next

If bFoundProperty = False Then
    WScript.Echo "Requested class instance was found but the property was not found. Exiting without making any changes."
    WScript.Quit(4)
End If 

' Property found. Check to see if existing value matches, change it as appropriate - on failure to save, report the error and exit.

If objProp.Value = NewValue Then
    WScript.Echo "Property '" & Property_Name & "' found and matches the new value '" & NewValue & "'. Not making any changes."
    WScript.Quit(0)
Else
    OriginalValue = objProp.Value
    objProp.Value = NewValue
    objProp.Put_
    objInst.Put_

    If Err.Number <> 0 Then
        wscript.Echo "Failed to save the change with error code: " & Err.Number & ". Exiting!"
        WScript.Quit(5)
    Else
        WScript.Echo "Property '" & Property_Name & "' successfully change from '" & OriginalValue & "' to '" & NewValue & "'."
    End If
End If

 

Besides, you can modify the class/property names in the script to modify other values to customize your site configuration.

 

Thanks,

Fei