I recently integrated the with Tableau server and with the requirement to ensure the Rserve process was running at computer startup, as the process is not implemented as a Windows service. The below assumes the Rserve package has been installed using the R server console prior to running the below.
Firstly, I wanted to ensure that there was no dependency on hard coding the version of R into the script which invoked the Rserve process, so I returned the install path from the registry.
$InstallPath = (Get-ItemProperty HKLM:\SOFTWARE\R-core\R64).InstallPath
I will then use conditional logic to determine if the Rserve executable is present in the install path directory.
If (-not (Test-Path $InstallPath\bin\x64\Rserve.exe)) { Copy-Item $InstallPath\library\Rserve\libs\x64\Rserve.exe -Destination $InstallPath\bin\x64\ }
Now, I will be required to invoke the Rserve process and suppress the command prompt.
$Command = "& '$InstallPath\bin\x64\Rserve.exe' %*" Invoke-Expression $Command
I then called the script as a scheduled task where the trigger was configured to run at computer startup.
The above is a similar process to that recommend in the R implementation notes in the Tableau Knowledge Base Article at http://kb.tableausoftware.com/articles/knowledgebase/r-implementation-notes.
The above allows me to run a single script on any version of R where the Rserve package has been installed and also with my preferred scripting language in Windows.