|
Const Impersonate = 3
' 暗号化は 6
' **********************************************************
' WMI 接続
' **********************************************************
Function WMIConnect()
strServer = document.all("Server").value
if strServer = "" then
strServer = "."
end if
strUser = document.all("User").value
strPassword = document.all("Password").value
' 接続
on error resume next
' ロケータ
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
if Err.Number <> 0 then
alert(Err.Description)
WMIConnect = False
Exit Function
end if
' サービス
Set objService = objLocator.ConnectServer( _
strServer, _
"root\cimv2", _
strUser, _
strPassword _
)
if Err.Number <> 0 then
alert(Err.Description)
WMIConnect = False
Exit Function
end if
' セキュリティ
objService.Security_.ImpersonationLevel = Impersonate
if Err.Number <> 0 then
alert(Err.Description)
WMIConnect = False
Exit Function
end if
on error goto 0
WMIConnect = True
End Function
| |