Here is an example of how to execute the Windows CMD command or PowerShell from R script. You can run cmd.exe by using the system function, and input might be something that you can run in CMD.
In this case, PowerShell and a relevant script from R.
system("cmd.exe", input = paste("powershell C:\\My\\location\\update_files.ps1"))
Sometimes it might be useful when something specific could be done faster in PowerShell than R.
When it something too complicated to execute in Windows CMD, you can run a batch file from R.
system("cmd.exe", input = paste("C:\\This\\Is\\Path\\Your.bat"))
Here is another example of how to run R script from R script by using Windows CMD.
Leave a Reply