Run Rscript.exe with VBScript and spaces in path -


i have followaing run.vbs script

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 & " " & ropts & " " & rscriptfile & " 1> " & outfile & " 2>&1"  intwindowstyle = 0   ' hide window , activate window.' bwaitonreturn  = false ' continue running script after launching r   '  ' following sub call, no parentheses around arguments'  createobject("wscript.shell").run strcommand, intwindowstyle, bwaitonreturn wscript.sleep 1000 createobject("wscript.shell").run startchrome, intwindowstyle, bwaitonreturn 

it works pretty in cases except when user puts run.vbs script in folder spaces in name: e.g. if run.vbs in folder "foo bar", user gets error : "c:\users\[user name]\desktop\foo" not recognized internal command...

i don't understand why rscript.exe looks absolute path before running if it's called parent directory using relative path.

i heard double quote solution using absolute path doesn't seem work .exe scripts (it though .bat , .cmd)

thanks help!

below code you

dim oshell object  set oshell = createobject("wscript.shell")     'run command'     dim oexec object     dim ooutput object     set oexec = oshell.exec("c:\program files\r\r-3.2.3\bin\rscript.exe c:\subfolder\yourscript.r " & """" & var1 & """")     set ooutput = oexec.stdout 

handle results written , read stdout object

dim s string dim sline string while not ooutput.atendofstream     sline = ooutput.readline     if sline <> "" s = s & sline & vbcrlf wend 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -