Freigeben über


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

Comments

  • Anonymous
    January 22, 2014
    Thanks a lot!!! Very hard solution!!! worked fine to me!!!

  • Anonymous
    September 22, 2014
    Thank you.   Note - in your script you're missing the quotes around 600.  I think most SCCM admins would see that though - I hope ;-)

  • Anonymous
    November 09, 2014
    Thank you for this nice contribution. It was a perfect solution for my problem.Good job!!

  • Anonymous
    January 15, 2015
    Thanks for this script, I've changed the value on my primary site server, but my clients not picking up this change. Clients still have the default value of 60.

  • Anonymous
    March 12, 2015
    Try run it on CAS if you are in a hierarchy-

  • Anonymous
    March 12, 2015
    I'm trying this script now and it returned the successful result for both my CAS and three primaries. Clients have yet to update.

  • Anonymous
    March 18, 2015
    Updated value on all site servers and CAS. New Client policy deployed to clients, value still unchanged. FAIL

  • Anonymous
    March 18, 2015
    Hi I tried it on cas and primary server but still it does not change the value on the clients??

  • Anonymous
    June 18, 2015
    I updated the value on my Primary and the client are not downloading the change with policy.  Has anyone got this to work??? Running SCCM 2012 R2 CU5.

  • Anonymous
    June 18, 2015
    I actually found the update on all my agents using PolicySpy from the 2012 toolkit.  You need to look under Machine/Settings/CCM_ConfigurationManagementClientConfig/SiteSettingsKey/ScriptExecutionTimeOut.  So all of my agents did pickup the change after policy ran. I hope this helps.

  • Anonymous
    September 22, 2015
    Hi Ballone, i am looking for "Machine/Settings/CCM_ConfigurationManagementClientConfig/SiteSettingsKey/ScriptExecutionTimeOut" is it under registry? or in WMI?

  • Anonymous
    September 28, 2015
    There is a known issue when changing the value to 600. Increase the value to 601 and it should work.