R and RStudio with Config

email me

Installing RStudio can present a couple of challenges.

One: To install RStudio, ‘R’ also has to be installed; RStudio uses R as a core application.
Two: You may want to use a custom config file to store “global” settings.

Step 1

To install R as a prerequisite program, just add the following to your deployment script

R_App_3.3.0.exe” /silent


Step 2

Next, add the silent setup for RStudio with

RStudio_Desktop.exe” /S


Step 3

Next, to distribute the global config file, first set all the options you would like distributed to all users; for me, I disabled the automatic updates. I launched RStudio, and deselected the Automatically Notify option.

Then, grab the user-settings file from

%userprofile%\AppData\Local\RStudio-Desktop\monitored\user-settings


Step 4

Use this script to distribute the user-setting file to all user profiles. Just add a line to your deployment script pointing to this VBS.

Distribution Script

on error resume next

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Const HKEY_LOCAL_MACHINE = &H80000002
Const OverwriteExisting = TRUE

'SETS CURRENT DIRECTORY TO VARIABLE
strCurrentDirectory = objShell.CurrentDirectory

'SETS CURRENT COMPUTER NAME
strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
For Each objSubkey In arrSubkeys
on error resume next
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
Const POPUP_TITLE = "User To SID Conversion"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set objAccount = objWMIService.Get("Win32_SID.SID='" & objSubkey & "'")
strUser = objAccount.AccountName
'strDomain = objAccount.ReferencedDomainName'returns referenced domain

'DISPLAY PROFILE NAME & SID
objSubkey = trim(objSubkey)'trims whitespace
strUser = trim(strUser)'trims whitespace
'msgbox "objSubkey: " & objSubkey'returns SID
'msgbox strUser'returns username

'LOGIC TO DETERMINE IF REGISTRY ACCOUNT IS TO BE LOADED
if strUser = "SYSTEM" then strUser=""
if strUser = "LOCAL SERVICE" then strUser=""
if strUser = "NETWORK SERVICE" then strUser=""
'if strUser = "ADMINISTRATOR" then strUser=""

'COPY CUSTOM CONFIG TO EACH USER PROFILE
if strUser <> "" then
on error resume next
'USED LOW LEVEL COPYING BECAUSE IT WORKS BETTER IN DEPLOYMENTS
objShell.Run "%comspec% /c md " & chr(34) & "C:\users\" & strUser & "\AppData\Local\RStudio-Desktop\monitored\user-settings\" & chr(34),0,true
Wscript.Sleep 1000
objShell.Run "%comspec% /c copy /y " & chr(34) & strCurrentDirectory & "\user-settings" & chr(34) & " " & chr(34) & "C:\users\" & strUser & "\AppData\Local\RStudio-Desktop\monitored\user-settings\" & chr(34),0,true
Wscript.Sleep 1000

end if

Next

 

This is what the setting looks like.

1 – Where the user-settings file is located
2 – The particular Automatically Notify for Updates setting in the user-settings file
3 – The Automatically Notify for Updates option in the GUI

 

The full user-settings file

alwaysSaveHistory=”1″
cleanTexi2DviOutput=”1″
cleanupAfterRCmdCheck=”1″
contextIdentifier=”2D6BC5AD”
cranMirrorCountry=”us”
cranMirrorHost=”RStudio”
cranMirrorName=”Global (CDN)”
cranMirrorUrl=”https://cran.rstudio.com/”
enableLaTeXShellEscape=”0″
errorHandlerType=”1″
hideObjectFiles=”1″
initialWorkingDirectory=”~”
lineEndingConversion=”2″
loadRData=”1″
newlineInMakefiles=”1″
removeHistoryDuplicates=”0″
restoreLastProject=”1″
reuseSessionsForProjectLinks=”1″
rprofileOnResume=”0″
saveAction=”-1″
securePackageDownload=”1″
showLastDotValue=”0″
showUserHomePage=”sessions”
uiPrefs=”{\n \”always_complete_characters\” : 3,\n \”always_complete_console\” : true,\n \”always_complete_delay\” : 250,\n \”always_enable_concordance\” : true,\n \”auto_append_newline\” : false,\n \”auto_expand_error_tracebacks\” : false,\n \”background_diagnostics_delay_ms\” : 2000,\n \”blinking_cursor\” : true,\n \”check_arguments_to_r_function_calls\” : false,\n \”check_for_updates\” : false,\n \”clear_hidden\” : false,\n \”code_complete\” : \”always\”,\n \”code_complete_other\” : \”always\”,\n \”continue_comments_on_newline\” : false,\n \”default_encoding\” : \”\”,\n \”default_latex_program\” : \”pdfLaTeX\”,\n \”default_project_location\” : \”~\”,\n \”default_sweave_engine\” : \”Sweave\”,\n \”diagnostics_in_function_calls\” : true,\n \”diagnostics_on_save\” : true,\n \”enable_background_diagnostics\” : true,\n \”enable_emacs_keybindings\” : false,\n \”enable_rstudio_connect\” : false,\n \”enable_snippets\” : true,\n \”enable_style_diagnostics\” : false,\n \”focus_console_after_exec\” : false,\n \”font_size_points\” : 10,\n \”handle_errors_in_user_code_only\” : true,\n \”highlight_r_function_calls\” : false,\n \”highlight_selected_line\” : false,\n \”highlight_selected_word\” : true,\n \”ignore_uppercase_words\” : true,\n \”ignore_words_with_numbers\” : true,\n \”insert_matching\” : true,\n \”insert_numbered_latex_sections\” : false,\n \”insert_parens_after_function_completion\” : true,\n \”insert_spaces_around_equals\” : true,\n \”navigate_to_build_error\” : true,\n \”num_spaces_for_tab\” : 2,\n \”packages_pane_enabled\” : true,\n \”pane_config\” : {\n \”consoleLeftOnTop\” : false,\n \”consoleRightOnTop\” : true,\n \”panes\” : [\n \”Source\”,\n \”Console\”,\n \”TabSet1\”,\n \”TabSet2\”\n ],\n \”tabSet1\” : [\n \”Environment\”,\n \”History\”,\n \”Build\”,\n \”VCS\”,\n \”Presentation\”\n ],\n \”tabSet2\” : [\n \”Files\”,\n \”Plots\”,\n \”Packages\”,\n \”Help\”,\n \”Viewer\”\n ]\n },\n \”pdf_previewer\” : \”desktop-synctex\”,\n \”preferred_document_outline_width\” : 110,\n \”print_margin_column\” : 80,\n \”reindent_on_paste\” : true,\n \”restore_source_documents\” : true,\n \”rmd_preferred_template_path\” : \”\”,\n \”rmd_viewer_type\” : 0,\n \”root_document\” : \”\”,\n \”save_before_sourcing\” : true,\n \”save_files_before_build\” : false,\n \”show_diagnostics_cpp\” : true,\n \”show_diagnostics_other\” : true,\n \”show_diagnostics_r\” : true,\n \”show_doc_outline_rmd\” : false,\n \”show_indent_guides\” : false,\n \”show_inline_toolbar_for_r_code_chunks\” : true,\n \”show_invisibles\” : false,\n \”show_line_numbers\” : true,\n \”show_margin\” : false,\n \”show_publish_ui\” : true,\n \”show_signature_tooltips\” : true,\n \”show_unnamed_chunks_in_document_outline\” : true,\n \”soft_wrap_r_files\” : false,\n \”source_with_echo\” : false,\n \”spelling_dictionary_language\” : \”en_US\”,\n \”strip_trailing_whitespace\” : false,\n \”surround_selection\” : \”quotes_and_brackets\”,\n \”syntax_color_console\” : false,\n \”tab_multiline_completion\” : false,\n \”theme\” : \”TextMate\”,\n \”toolbar_visible\” : true,\n \”use_rcpp_template\” : true,\n \”use_roxygen\” : false,\n \”use_spaces_for_tab\” : true,\n \”use_vim_mode\” : false,\n \”valign_argument_indent\” : true,\n \”warn_if_no_such_variable_in_scope\” : false,\n \”warn_if_variable_defined_but_not_used\” : false\n}”
useDevtools=”1″
useInternet2=”1″
vcsEnabled=”1″
vcsGitExePath=””
vcsSvnExePath=””
vcsTerminalPath=””
vcsUseGitBash=”1″
viewDirAfterRCmdCheck=”0″