| - WMI Fun !! -|WMI Step|WMI Sample|Search|WMI Fun !! Groups|About WMI Fun !! | ||||||
| Top Page >> WMI Step >> リモートデスクトップを有効にする | ||||||
|
リモートデスクトップを有効にする
■Topicsリモートデスクトップ接続を有効にするサンプルです。Win32_TerminalServiceSettingクラスを使用します。 Private Sub Command1_Click()
Dim TsSet As SWbemObjectSet
Dim Ts As SWbemObject
Dim Locator As SWbemLocator
Dim Service As SWbemServices
Dim Ret As String
Set Locator = New WbemScripting.SWbemLocator
Set Service = Locator.ConnectServer
Set TsSet = Service.ExecQuery("Select * From Win32_TerminalServiceSetting")
For Each Ts In TsSet
Ret = Ts.SetAllowTSConnections(1)
Next
If Ret = 0 Then
MsgBox "リモートデスクトップを有効にしました。"
Else
MsgBox "リモートデスクトップを有効にできませんでした。"
End If
Set TsSet = Nothing
Set Ts = Nothing
Set Locator = Nothing
Set Service = Nothing
End Sub
実行するとリモートデスクトップ接続を有効に変更します。SetAllowTSConnectionメソッドの引数を「0」に変えれば逆に向こうに変更することが可能です。
WMI を本で勉強したい方へ。
なかなか WMI のことが乗っている書籍は少ないですが…管理系業務に係る方には楽しめるかも? |
|
| ^ | Copyright(C) 1997-2008 とお All rights reserved. | << |