Run Rscript.exe with VBScript and spaces in path
<p>I have the followaing run.vbs script</p>

<pre><code>Rexe           = "R-Portable\App\R-Portable\bin\Rscript.exe"
Ropts          = "--no-save --no-environ --no-init-file --no-restore --no-Rconsole "
RScriptFile    = "runShinyApp.R"
Outfile        = "ShinyApp.log"
startChrome    = "GoogleChromePortable\App\Chrome-bin\chrome.exe --app=http://127.0.0.1:9999"
strCommand     =  Rexe &amp; " " &amp; Ropts &amp; " " &amp; RScriptFile &amp; " 1&gt; " &amp; Outfile &amp; " 2&gt;&amp;1"

intWindowStyle = 0   ' Hide the window and activate another window.'
bWaitOnReturn  = False ' continue running script after launching R   '

' the following is a Sub call, so no parentheses around arguments'

CreateObject("Wscript.Shell").Run strCommand, intWindowStyle, bWaitOnReturn
WScript.Sleep 1000
CreateObject("Wscript.Shell").Run startChrome, intWindowStyle, bWaitOnReturn
</code></pre>

<p>It works pretty well in most cases except when the user puts the run.vbs script in a folder with spaces in its name: e.g. if run.vbs is in folder "foo bar", the user gets the error : "C:\Users\[user name]\Desktop\foo" not recognized as internal command...</p>

<p>I don't understand why Rscript.exe looks for the absolute path before running even if it's called from its parent directory using relative path.</p>

<p>I heard about the double quote solution using the absolute path but it doesn't seem to work with .exe scripts (it does though with .bat and .cmd)</p>

<p>Thanks for any help!</p>