Permalink
Browse files

childprocess: make batch file processing generic, handle any file type

Non-executable files, including batch (*.bat) files, must be run under cmd.exe
This allows launching any type of file that cmd.exe knows how to handle, i.e. PDF, PNG, JPG, etc
  • Loading branch information...
robertwahler committed Jun 16, 2012
1 parent 998702b commit 67685b31339ee0ca637fb7844a27a35887613884
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/childprocess/windows/process_builder.rb
@@ -42,10 +42,13 @@ def start
def create_command_pointers
string = @args.map { |arg| quote_if_necessary(arg.to_s) }.join ' '
- # .bat file handling, must be run under cmd.exe
+ # Non-executable files, including batch (*.bat) files, must be run under cmd.exe
+ #
+ # This allows launching any type of file that cmd.exe knows how to handle, i.e. PDF, PNG, JPG, etc
if string && @app_name.nil?
- batch_file = string.match(/'?"?.*\.bat\s?/) ? true : false
- if batch_file
+ # any exe file followed by a word boundary
+ non_executable = string.match(/^.+\.exe\b/) ? false : true
+ if non_executable
@app_name = quote_if_necessary(File.join(ENV["WINDIR"], "system32", "cmd.exe"))
string = "/c #{string}"
end

0 comments on commit 67685b3

Please sign in to comment.