From: Fengfeng Li Date: 2010-11-23T12:08:22+09:00 Subject: system() or process.create? Hi everyone, I'm a beginer of ruby, I want to know how to call external applications in ruby, without the cmd window poping up. I leanrt this link: http://www.ruby-forum.com/topic/213521#new, and tried all the below ways: result = `#{cmd}` #I tried this but the window still poped up result = IO.popen("#{cmd}").read #and the same with this one Process.create( :app_name => cmd, :startup_info=> {:sw_flags=>Process::SW_HIDE , :startf_flags => Process::STARTF_USESHOWWINDOW} ) #at last, I use process.create and the black window disappeared. It worked good when I set cmd as "\"#{winrar_path}\\winrar.exe\" e -y -o+ -ibck \"#{para[:dst_path]}\\*.zip\" \"#{para[:dst_path]}\\\"", but when I changed it to "del *.zip", it always said "CreateProcess() failed: ", as below: FileUtils.chdir("#{para[:dst_path]}") cmd = "del *.zip" Process.create(:app_name => cmd,:startup_info=> {:sw_flags=>Process::SW_HIDE , :startf_flags => Process::STARTF_USESHOWWINDOW} ) The other problem is, if I use Process.create to unzip some file firstly, and then use Process.create to do some other things to the new-unzip files secondly, the second application sometimes failed, I think maybe because the first unzip process is still processing? How to avoid this? Thanks:) Regards -- Posted via http://www.ruby-forum.com/.