0

I have below code in new.R file, which is working fine in RStudio interactive mode.

system_command <- paste("WScript", " C:/Users/OneDrive/Desktop/r1.vbs")
system(command = system_command)

But when I run the new.R file using Rscript, its not invoking the vbs script. Is there any other way to invoke vbs script in Rscript mode?

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • 1
    What error message do you get? How do you invoke your R file? Did you specify correct path for Rscript? – tacoman Dec 28 '20 at 14:27
  • Tangent: if you are certain that you will never have spaces or non-standard characters in your `vbs` filename, this may work, but if not you should really try to protect yourself from shell-isms. For instance, `system2("WScript", shQuote("c:/Users/..."))` is one start. Underneath it all, though, both `system` and `system2` are woefully inadequate when quoting arguments, as it just uses `paste` under the hood. A more robust option (imo) is to use `processx`, which properly passes arguments as-is without risk of space-delimited confusion. – r2evans Dec 28 '20 at 14:37
  • Thank you both of you, it's working in RScript, the was stoping execution because of error before reaching to a system command. – Saurabh Patel Dec 28 '20 at 16:35

0 Answers0