1

I am using this script to launch calculator program. How to add lines to close the calculator after 2 mins.

Set colMonitoredEvents = GetObject("winmgmts:")._
ExecNotificationQuery("SELECT * FROM Win32_PowerManagementEvent")

Do Set strLatestEvent = colMonitoredEvents.NextEvent If strLatestEvent.EventType = 4 Then Set objWMIService = GetObject("winmgmts:\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") For Each objItem in colItems If objItem.name = "Calculator.exe" then objItem.terminate Next ElseIf strLatestEvent.EventType = 7 Then Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.Run "calc.exe", 1, false End If Loop

DavidPostill
  • 156,873
VB88
  • 393

0 Answers0