我正在尝试将一个vbscript附加到我的Windows调度程序上,这样一旦我打开一个程序(例如Google Chrome),它就会在后台运行一个excel宏。我查看了任务调度程序,无法找到基于打开另一个程序而触发事件的能力,而不是管理消息或错误。抱歉,这是一个菜鸟问题!
答案 0 :(得分:0)
这是来自Windows SDK WMI部分。 http://msdn.microsoft.com/en-us/library/aa392396(v=vs.85).aspx
此监视器6(i = 0到5)程序启动并退出。
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\CIMV2")
Set objEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM Win32_ProcessTrace")
Wscript.Echo "Waiting for events ..."
i = 0
Do Until i=5
Set objReceivedEvent = objEvents.NextEvent
'report an event
Wscript.Echo "Win32_ProcessTrace event occurred" & VBNewLine _
& "Process Name = " _
& objReceivedEvent.ProcessName & VBNewLine _
& "Process ID = " _
& objReceivedEvent.Processid & VBNewLine _
& "Session ID = " & objReceivedEvent.SessionID
i = i+ 1
Loop