문제

I want to create a Windows Task Scheduler that will check whether rubyw.exe is running or not in window processes . if it is not running then Scheduler will run a C:/test.rb file and if it is running then do nothing.

how can i do it? in ruby and php

도움이 되었습니까?

해결책

Okay! So you can take the approach as below using WMI and WIN32OLE

require 'win32ole'

wmi = WIN32OLE.connect("winmgmts://")
processes = wmi.ExecQuery("select * from win32_process")
ar = processes.each.with_object([]) {|i,a| a << i.name }
# => ["System Idle Process", "System", "smss.exe", "csrss.exe",...]
if ar.include? "rubyw.exe"
 #run a C:/test.rb file
else
 # do nothing
end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top