0
我知道在窗戶打開CMD的一個實例,並獲得返回代碼返回由win32ole模塊打開的CMD的HIDE實例的exitcode?
puts %x[Tasklist /v | Find "%tmp:~0,30%" >NUL]
response = $?.exitstatus
的作品。
但是現在我需要打開一個CMD的隱藏實例,我只知道用Win32ole模塊來做,而funcion「exitstatus」給我一個錯誤。 我不知道爲什麼...
請幫助獲取該實例的退出代碼,或以另一種方式打開(並獲取退出代碼) 隱藏實例。
require 'win32ole'
shell = WIN32OLE.new('Shell.Application')
shell.ShellExecute('CMD', '/K Tasklist /v | Find "%tmp:~0,30%" >NUL',
'', '', 0)
response = $?.exitstatus
if response == 0
puts "hola"
end
未定義的方法`退出狀態的零:NilClass
NoMethodError
你是什麼意思是「隱藏的CMD的實例」? – 2012-03-04 17:28:40
你沒有定義'response',也許你打算使用'response = shell.ShellExecute(...)'。 – Koraktor 2012-03-05 22:28:36