Execute-Process -Path Issue

I’m creating a appdeploy script to install the latest R stat program plus packages.

The R install goes fine with no issues, but in the Post-Installation where I try to install the Packages, I’m having issues

With R you install the add on packages, but starting the R program with the CMD Install PackageName

So I tried:

Execute-Process -Path "$envProgramFiles\R\R-3.2.1\bin\R.exe -Parameters “CMD Install $dirFiles\nameofpackage.zip”

When run from the script, it resolves the $envProgramFiles to C:\Program Files correct and the
$dirFiles correctly and tries to run the command. It comes back with exit code of 0, but no package is installed.

When I run the same command from a command prompt, I have to use:

“C:\Program Files\R\R-3.2.1\bin\R.exe” CMD Install PathtoFiles\nameofpackage.zip

So I wonder if I need to escape the " " blank space in Program Files somehow?

Thanks

You’re missing a quotation mark in your command. It should be like this:
Execute-Process -Path “$envProgramFiles\R\R-3.2.1\bin\R.exe” -Parameters “CMD Install $dirFiles\nameofpackage.zip”

Also, in case $dirFiles has spaces in it, you should probably also do this:

Execute-Process -Path "$envProgramFiles\R\R-3.2.1\bin\R.exe" -Parameters "CMD Install `"$dirFiles\nameofpackage.zip`""

Yes, I forgot to type in the closing " in Path, but it’s there in the script.

The dirfiles path has no spaces. So that’s not it.

When I tried to use the ` symbol in the -Path parameter (in case it doesn’t like the space in Program Files) I get an Illegal character failture

If you got an illegal character failure for using `, then it was specified improperly. I don’t think there is a problem with the $envProgramFiles path. If Execute-Process is executing the exe and returning a 0 exit code, then I assume the package is being executed with the correct commandline. Question is why it doesn’t behave as expected and install the application. Is there a log that is generated?