Unlike system() , the command argument to system2() always enclosed in shQuote quotes, so it must be a single command with no arguments, while arguments are passed to command with the args argument.
They both work:
system("sed -i 's/oldword\\s/oldword/g' d:/junk/x/test.tex") system2("sed", args=c("-i", "s/oldword\\s/newword/g", "d:/junk/x/test.tex"))
I would try:
system2("powershell", args=c("-file", "C:\\directoryName\\coolScript.ps1"))
Another thing you should be aware of is that there are two versions of the R executable: R-3.2.1 \ bin \ i386 (32-bit) and R-3.2.1 \ bin \ x64 (64-bit version). By default, only the first is installed on 32-bit versions of Windows, but both are on 64-bit operating systems. The 32-bit version of R will invoke the 32-bit version of PowerShell for the same version for the 64-bit version, so be careful to use Set-ExecutionPolicy for the correct version.
source share