How to deploy a Shiny app as a portable desktop app for Windows?

4,486 views
Skip to first unread message

ZJ

unread,
Jan 10, 2014, 4:54:18 AM1/10/14
to shiny-...@googlegroups.com
I want to ship my ShinyApp as a portable desktop app for Windows. I want to it to be portable so as to minimize friction in take-up. My app is aimed at corporates but they usually have strict software installation policies so normal users can't usually install new software.

I managed to find portable-R and portable-Chrome from portableapps.com. But if I try to create a batch (.bat) file to fire-up batch mode R which then fires the Shiny-app I will get a black window for the .bat file. What's a nicer way to do this? So that my apps looks a native as possible (even though portable Chrome will popup).

I am also investigating this myself but just wondering if the good people here have any experience doing similar things before (or you all look down on Windows users like me, haha). Hope to write up a tutorial on this to help others once I find a good solution.

Joe Cheng

unread,
Jan 10, 2014, 5:10:52 AM1/10/14
to ZJ, shiny-...@googlegroups.com
In the past I've done this with other languages like C, C#, and Java (which comes with javaw.exe IIRC). But apparently you can just use Windows Scripting Host:


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ZJ

unread,
Jan 13, 2014, 10:27:32 AM1/13/14
to shiny-...@googlegroups.com, ZJ
I've got quite far. But it seems that running Shiny in batch mode won't launch the browser. Nevermind the following script can start the browser after launch R

'HideBat.vbs
CreateObject("Wscript.Shell").Run "yourBatch.bat", 7, False
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""GoogleChromePortable\GoogleChromePortable.exe""")
Set objShell = Nothing

However now I run into two problems:

1. Sometimes shiny can take a few seconds to start so chrome can get started before Shiny initialise which leads to url not found error.
2. How do I know to close the program when chrome closes?

Looking into other possible vbs script solutions. Please suggest if you can think of anything!

Stéphane Laurent

unread,
Jan 13, 2014, 3:44:50 PM1/13/14
to shiny-...@googlegroups.com, ZJ
running Shiny in batch mode won't launch the browser

In batch mode, you need to set the option launch.browser=TRUE of the runApp() function.

ZJ

unread,
Jan 13, 2014, 8:28:51 PM1/13/14
to shiny-...@googlegroups.com, ZJ
I see. Can't believe I missed this. So one last remaining

How to reliably close the app!

Vincent Nijs

unread,
Jan 14, 2014, 11:54:24 AM1/14/14
to shiny-...@googlegroups.com, ZJ
I am interested in how you are using ChromPortable. Can you share more on your approach?

I used the command below in a .bat file for my students on windows to start the app. The locale command was needed to get the app to work for those that did not have locale set to English.

C:\PROGRA~1\R\R-30~1.2\bin\x64\R.exe -e "Sys.setlocale(category = 'LC_ALL','English_United States.1252'); shiny::runApp('~/../Desktop/radyant/', port = 8100, launch.browser=TRUE)"

I have something similar for mac using an automator script. Let me know if you are interested.


session$onSessionEnded(function() { q("no") })

This stops everything when the user closes the browser window. However it also stops on browser refresh which is a problem for the load/save/reset state functions in my app.

Now I use the following observer in linked to an action button. This shuts down R but it leaves the browser window open.

observe({
  if(is.null(input$quitApp) || input$quitApp == 0) return()
  stopApp()
  q("no")
})

In sum ... no full solution. Hope this still helps a bit.

ZJ

unread,
Jan 14, 2014, 10:38:53 PM1/14/14
to shiny-...@googlegroups.com, ZJ
I do two things with my Chrome Portable. Firstly I do options(browser="path/GoogleChromePortable.exe") so that when shiny launches the portable browser. Secondly I follow http://portableapps.com/node/27886 and use the GoogleChromePortable.ini files and launch chrome in app mode (without address bar etc) so it looks like an app. 
e.g. with an setting like this
app="http://localhost::8100"

ZJ

unread,
Mar 17, 2014, 2:30:09 PM3/17/14
to shiny-...@googlegroups.com, ZJ
I've written a quick tutorial on how to make your Shiny app into a portable Windows Desktop App.


Please post comments/questions to try and help me get this to be more polished!
Reply all
Reply to author
Forward
0 new messages