Partager via


How to Enable and Disable Remote Tools

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

You enable or disable the Remote Tools Client Agent, in Microsoft System Center Configuration Manager 2007, by modifying the site control file settings.

To enable or disable the Remote Tools Client Agent

  1. Set up a connection to the SMS Provider.

  2. Make a connection to the Remote Tools Client Agent section of the site control file by using the SMS_SCI_ClientComp class.

  3. Loop through the array of available properties, making changes as needed.

  4. Commit the changes to the site control file.

Example

The following example method enables or disables the Remote Tools Client Agent by using the SMS_SCI_ClientComp class to connect to the site control file and change properties.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Sub EnableDisableRemoteControlClientAgent(swbemServices,   _
                                          swbemContext,    _
                                          siteCode,    _
                                          enableDisableClientAgent)

    ' Load site control file and get client component section.
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Refresh", , , swbemContext
    Set objSWbemInst = swbemServices.Get("SMS_SCI_ClientComp.Filetype=1,Itemtype='Client Component',Sitecode='" & siteCode & "',ItemName='Remote Control'", , swbemContext)
    
    ' Display client agent settings before change.
    Wscript.Echo " "
    Wscript.Echo "Properties - Before Change"
    Wscript.Echo "---------------------------"
    Wscript.Echo objSWbemInst.ClientComponentName
    Wscript.Echo objSWbemInst.Flags & " (0 = Disabled, 1 = Enabled)"
    
    ' Set the client agent by setting the Flags value to 0 or 1 using the enableDisableClientAgent variable.
    objSWbemInst.Flags = enableDisableClientAgent
    
    ' Save the new client agent settings.
    objSWbemInst.Put_ , swbemContext
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Commit", , , swbemContext
    
    ' Refresh the in-memory copy of the site control file and get the client component section.
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Refresh", , , swbemContext
    Set objSWbemInst = swbemServices.Get("SMS_SCI_ClientComp.Filetype=1,Itemtype='Client Component',Sitecode='" & siteCode & "',ItemName='Remote Control'", , swbemContext)
    
    ' Display the client agent settings after the change.
    Wscript.Echo " "
    Wscript.Echo "Properties - After Change"
    Wscript.Echo "---------------------------"
    Wscript.Echo objSWbemInst.ClientComponentName
    Wscript.Echo objSWbemInst.Flags & " (0 = Disabled, 1 = Enabled)"
    
    ' Release the copy of the site control file.
    swbemServices.Get("SMS_SiteControlFile").ReleaseSessionHandle swbemContext.Item("SessionHandle").Value

End Sub
public void EnableDisableRemoteControlClientAgent(WqlConnectionManager connection,
                                                  string siteCode,
                                                  string enableDisableClientAgent)
{
    try
    {
        IResultObject siteDefinition = connection.GetInstance(@"SMS_SCI_ClientComp.FileType=1,ItemType='Client Component',SiteCode='" + siteCode + "',ItemName='Remote Control'");

        // Display Remote Control client agent settings before changing the properties.
        Console.WriteLine();
        Console.WriteLine("Properties - Before Change");
        Console.WriteLine("---------------------------");
        Console.WriteLine(siteDefinition["ClientComponentName"].StringValue);
        Console.WriteLine(siteDefinition["Flags"].StringValue + " (0 = Disabled, 1 = Enabled)");

        // Set Remote Control client agent by setting "Flags" value to 0 or 1 by using the enableDisableClientAgent variable.
        siteDefinition["Flags"].StringValue = enableDisableClientAgent;

        // Save the settings.
        siteDefinition.Put();

        // Verify the change by reconnecting and getting the value again.
        IResultObject siteDefinition2 = connection.GetInstance(@"SMS_SCI_ClientComp.FileType=1,ItemType='Client Component',SiteCode='" + siteCode + "',ItemName='Remote Control'");

        // Display Remote Control client agent settings after changing the properties.
        Console.WriteLine();
        Console.WriteLine("Properties - After Change");
        Console.WriteLine("--------------------------");
        Console.WriteLine(siteDefinition2["ClientComponentName"].StringValue);
        Console.WriteLine(siteDefinition2["Flags"].StringValue + " (0 = Disabled, 1 = Enabled)");
    }

    catch (SmsException ex)
    {
        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);
        throw;
    }

}

The example method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

siteCode

  • Managed: String

  • VBScript: String

The site code.

enableDisableClientAgent

  • Managed: String

  • VBScript: String

Determines whether the Remote Tools client agent is enabled or disabled.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.

See Also

Concepts

System Center Configuration Manager Software Development Kit
About Configuration Manager Remote Tools
About the Configuration Manager Site Control File
How to Read and Write to the Configuration Manager Site Control File by Using Managed Code
How to Read and Write to the Configuration Manager Site Control File by Using WMI
SMS_SCI_Component Server WMI Class