'*--------------------------------------------------------------------------------------- '* Windows Vista & Windows Server 2008?p?@OS?V???b?g?_?E?????s?X?N???v?g '* '* Windows Vista ?܂??́@Widnwos Server 2008?ɂ?OS?V???b?g?_?E???????s????ꍇ?? '* ???̃X?N???v?g???^?X?N?X?P?W???[???ɓo?^???邱?Ƃɂ???āAUSB?J?[?h?ł????ُ͈펞?? '* ?x?~??ԈȊO?ň??S??OS?V???b?g?_?E???????s?”\?ł??B '* '*--------------------------------------------------------------------------------------- On Error Resume Next strComputer = "." stopcounter = 0 Availability = 0 BatteryStatus = 0 EstimatedChargeRemaining = 0 Set colMonitoredEvents = GetObject("winmgmts:").ExecNotificationQuery("Select * from Win32_PowerManagementEvent") Do stopcounter = 0 Set strLatestEvent = colMonitoredEvents.NextEvent '* ?C?x???g?̎擾 Do Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_Battery",,48) For Each objItem in colItems Availability = objItem.Availability BatteryStatus = objItem.BatteryStatus EstimatedChargeRemaining = objItem.EstimatedChargeRemaining Next Wscript.Sleep(1000) If Availability = 3 then if BatteryStatus = 1 and EstimatedChargeRemaining = 0 and stopcounter < 10 Then stopcounter = stopcounter + 1 if stopcounter >= 10 then '* --------------------------------------------------------------------------------------------------------- '* ??????OS?V???b?g?_?E?????s???̏??????L?q???? Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems '* ObjOperatingSystem.Win32Shutdown(1) '* Shutdown '* ObjOperatingSystem.Win32Shutdown(5) '* Forced Shutdown '* ObjOperatingSystem.Win32Shutdown(8) '* Power Off ObjOperatingSystem.Win32Shutdown(12) '* Forced Power Off Next '* --------------------------------------------------------------------------------------------------------- end if end if Else Exit Do '* ?o?b?e???쓮???ȊO?̓C?x???g?擾?֖߂? End If Loop Loop