Creating stand-alone Shiny App - Chrome Error

I have solved it that way with a few changes to run.vbs and runShinyApp.R.

run.vbs:

Rexe           = "R-Portable\App\R-Portable\bin\R.exe CMD BATCH"
Ropts          = "--no-save --no-environ --no-init-file --no-restore --no-Rconsole "
RScriptFile    = "runShinyApp.R"
Outfile        = "ShinyApp.log"
startChrome    = "GoogleChromePortable\Chrome\chrome.exe --app=http://127.0.0.1:7777"
strCommand     = Rexe & " " & Ropts & " " & RScriptFile & " 1> " & Outfile & " 2>&1"

intWindowStyle = 0     ' Hide the window and activate another window.'
bWaitOnReturn  = False ' continue running script after launching R   '

' the following is a Sub call, so no parentheses around arguments'

CreateObject("Wscript.Shell").Run strCommand, intWindowStyle, bWaitOnReturn
CreateObject("Wscript.Shell").Run startChrome, intWindowStyle, bWaitOnReturn

I added the startChrome variable and call CreateObject after I start the server, because otherwise there is no website and Chrome does not automatically reload when you start it afterwards. Usually starting the server should be fast enough but if you are on a very slow machine it might take too long. Then you need to add a delay between the two CreateObject calls.

The --app setting opens the app in a window that does not have all the Google Chrome buttons and then it really looks like a standalone app.

runShinyApp.R:

require(shiny)
shiny::runApp('./shiny/',port=7777)

Port 7777 is arbitrary, you can use any free port you like. The port has to be same in all files.

In case you want to use a bat file:

SET ROPTS=--no-save --no-environ --no-init-file --no-restore --no-Rconsole
start /b GoogleChromePortable\Chrome\chrome.exe --app=http://127.0.0.1:7777
R-Portable\App\R-Portable\bin\R.exe CMD BATCH %ROPTS% runShinyApp.R 1> ShinyAppOut.log 2> ShinyAppMsg.log

I moved away from using the portable version of Chrome because of issues like this while developing the RInno package, which is based on Dr. Lee Pang's DesktopDeployR framework. The package helps automate this and incorporates Inno Setup installers so that non-technical users can install and use your Shiny apps.

To get started:

install.packages("RInno")
require(RInno)
RInno::install_inno()

Then you just need to call two functions to create an installation framework:

create_app(app_name = "myapp", app_dir = "path/to/myapp")
compile_iss()

If you would like to include R for your co-workers who don't have it installed, add include_R = TRUE to create_app:

create_app(app_name = "myapp", app_dir = "path/to/myapp", include_R = TRUE)

It defaults to include shiny, magrittr and jsonlite, so if you are using other packages like ggplot2 or plotly, just add them to the pkgs argument. You can also include GitHub packages to the remotes argument:

create_app(
    app_name = "myapp", 
    app_dir  = "path/to/myapp"
    pkgs     = c("shiny", "jsonlite", "magrittr", "plotly", "ggplot2"),
    remotes  = c("talgalili/installr", "daattali/shinyjs"))

If you are interested in other features, check out FI Labs - RInno