MSWin32 version of ruby provides Windows batch file that converted from original script files.
The batch file is not plain ruby script, so the patch provided by #3121 (comment) causes error on Windows.
c:/Users/arton/bin/ruby.exe c:/Users/arton/rake.bat assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
c:/Users/arton/bin/rake.bat:1: syntax error, unexpected tIDENTIFIER, expecting $end
Command failed with status (1): [c:/Users/arton/bin/ruby.exe c:/U... (omitted by the poster)
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
So, this patch checks $0 is batch file or not. And if $0 is batch file, then run it with Kernel.exec (means Win32 API) instead of ruby.
run direcly $0 if rake invoked by Windows batch file.