In the case of Windows, shelling out to perform the lookup was even more expensive than POSIX. What was done here is remove the dependency on `which.bat` support file and perform a direct lookup over ENV['PATH'] looking for the required executable. The approach taken will append '.exe' to supplied cmd name under Windows. Only .exe are truly executables and anything else (.bat, .vbs, .msc) can't be executed directly. To execute batch files (.bat, .cmd), Ruby wraps them with cmd.exe. Based on existing executables on the platform (node.exe, cscript.exe) and that .com hasn't been seen in the past 10 years (only for compatibility), the lookup over PATHEXT seems unnecessary.
…ces or reserved shell characters (on Windows). http://technet.microsoft.com/en-us/library/cc723564.aspx states that "all reserved shell characters not in double quotes must be escaped." It also states that "any argument that contains spaces...must be enclosed in double quotes" Furthermore, "if a double-quoted argument itself contains a double quote character, the double quote must be doubled."
Cope with @binary with values such as: C:\Windows\System32\cscript.exe //E:jscript //Nologo //U