WMI Fun !! 〜 WMI に興味がある方・システム管理者必見! 〜 |
|
![]() |
WMI Fun !! > WMI Sample (VB) > PC をシャットダウンする |
PC をシャットダウンする: Win32_OperatingSystem - WMI Sample (VB)Topics
WMI を使用して PC をシャットダウンするサンプルプログラムです。
Sample Code
Private Sub Command1_Click()
Dim OsSet As SWbemObjectSet Dim Os As SWbemObject Dim Locator As SWbemLocator Dim Security As SWbemSecurity Dim Service As Object Dim MesStr As String Const wbemPrivilegeShutdown = 18 Set Locator = New WbemScripting.SWbemLocator Set Security = Locator.Security_ Security.Privileges.Add wbemPrivilegeShutdown Set Service = Locator.ConnectServer Set OsSet = Service.ExecQuery _ ("Select * From Win32_OperatingSystem") For Each Os In OsSet Os.Shutdown Next Set OsSet = Nothing Set Os = Nothing Set Service = Nothing Set Locator = Nothing End Sub
![]() Comment
実行すると PC をシャットダウンしてしまいます。 ![]() Recommended book
個人的にお勧めする本の紹介です。 ![]() |
ご意見・ご要望・ご感想をこちらのアンケートからお待ちしています |
∧ ページの先頭へ… |