如何创建链接服务
设置 IPDLC 连接时,可能需要执行的另一项任务是创建链接服务。
创建链接服务
使用 GetObject 连接到本地计算机上的命名空间。
使用 SpawnInstance 创建新的链接服务实例。
设置新链接服务的属性。
使用 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