Blogging about Royal TS/X, Royal Server and Royal Passwords

Use a PowerShell Logon Script to Pre-Configure Royal TS Settings

Recently we got an interesting support request where a customer wanted to prepare the application settings, which are usually available in the Royal TS UI through View -> Options,  using a logon script in PowerShell.

I thought it would be a good idea to share this in a blog post because there are one or two caveats to watch out for but first, here’s the script:

# import the powershell module to get access to the cmd lets
Import-Module "C:\Program Files (x86)\code4ward.net\Royal TS V4\RoyalDocument.PowerShell.dll" -Force

# create a store
$store = New-RoyalStore -UserName $Env:USERNAME

# path to the app document
$appDocPath = "$Env:APPDATA\code4ward\code4ward.RoyalTS.UserPreferences.config"

# open the app document
$appDoc = Open-RoyalDocument -Store $store -FileName $appDocPath

# set all the options
$store.Options.DontShowDocumentModifiedNotification = $true
$store.Options.DontShowMaintenanceExtensionNotification = $true
$store.Options.DontShowRestoreConnectionsDialog = $true
$store.Options.DoNotCreateDashboardOnStartup = $true
$store.Options.DoNotShowGettingStartedPageOnStartup = $true
$store.Options.SuperStartPageBehavior = 0
$store.Options.AutoStartDocumentMode = 3

# here we need an array of strings with the full path to all the docs we want to open automatically
$store.Options.AutoStartDocumentList = @( "FullDocumentPath1", "FullDocumentPath2" )

# this saves the document as "*.rtsz"
Out-RoyalDocument -Document $appDoc -FileName $appDocPath
Close-RoyalDocument -Document $appDoc

# now we need to delete the old .config file and rename the .rtsz file
Remove-Item -Path $appDocPath
Rename-Item -Path "$appDocPath.rtsz" -NewName $appDocPath

Now to the two caveats:

  1. The property AutoStartDocumentList must be set using a string array – even if you only set one path.
  2. When you invoke the Out-RoyalDocument cmdlet, the file will be “*.rtsz” but the extension for this particular file must be “*.config”. That’s why we have the last two lines of code (Remove-Item and Rename-Item) in the script.


You must be logged in to post a comment.