如何建立連結服務

設定 IPDLC 連線時,您可能想要執行的另一項工作是建立連結服務。

  1. 使用 GetObject連線到本機電腦上的命名空間。

  2. 使用 SpawnInstance建立新的連結服務實例。

  3. 設定新連結服務的屬性。

  4. 使用 Put_ 方法,將新的實例認可至記憶體。

    下列範例示範如何建立新的連結服務:

private Sub CreateIPDLCLinkService  
    on error resume next  
' Connect to the namepsace on the local machine  
    Set Namespace = GetObject("Winmgmts:root\MicrosoftHIS")  
    Set ObjClass  = Namespace.Get("MsSna_LinkService_IpDlc")     
' Create new link service instance  
    Set NewInst   = ObjClass.SpawnInstance_  
    ' Set instance properties  
    NewInst.NetworkName = Left(strComputerName, 8)  
    NewInst.CPName = "IPDLCLS"  
    NewInst.NodeID = "05D.FFFFF"  
    NewInst.AddressType = 2  
    NewInst.LocalAddress = Trim(strLocalAddress)  
    NewInst.LENNode = strLenNode  
    NewInst.PrimaryNNS = strPrimaryNNS  
    if (strBackupNNS <> Empty) then  
        NewInst.BackupNNS = strBackupNNS  
    end if  
    ' Commit the instance  
    NewInst.Put_  
    if Err.Number <> 0 then  
        PrintWMIErrorThenExit Err.Description, Err.Number  
        Wscript.Echo "Link Service Creation Failed " & Err.Description  
    Else   
        Wscript.Echo "Link Serice Created Successfully"  
    end if  
End Sub