R system functions always returns error 127

system("bash -l", input = "notepad")

Adapting @DavidTseng's answer (sorry for not having enough reputation to upvote it)...

system("cmd.exe", input = "notepad")

worked for me in Windows.


As I mentioned in my comments, the R documentation reveals that in Windows the system() function does not launch a separate shell (if needed). This is why command line commands run with system(), but Notepad, which needs a separate window, does not run:

From the documentation for system():

The most important difference is that on a Unix-alike system launches a shell which then runs command. On Windows the command is run directly – use shell for an interface which runs command via a shell (by default the Windows shell cmd.exe, which has many differences from a POSIX shell).