You can execute shell scripts on your servers at different phases of a session lifecycle.
Examples include:
- Session startup and close
- Application startup and close
Scripting on Windows
Events and timingThe name portion of the script file determines its execution mode:
StartupBefore/StartupAfter[Sync].[bat/exe/ps1]
- StartupBefore: script will execute before the session's module (executable). For example, if the session is intended to launch WordPad.exe, the script will launch before WordPad executes.
- StartupAfter: script will execute after the session's module (executable), but right before opening the session (before hiding the "Connecting" HTML screen and showing the app session to user). For example, if the session is intended to launch WordPad.exe, the script will launch after WordPad executes.
- StartupEarly: script will execute before the session's module, and even before any session preparation (i.e. environment variables, storage virtualization) is made by Cameyo. This is recommended for special cases only.
- *Sync: an optional suffix which blocks the workflow until the script finishes execution. Example: StartupBeforeSync.bat -> session will wait for script to finish before starting the session's application.
StartupSystem.[bat/exe/ps1]
- StartupSystem: script will execute as SYSTEM user, hence with maximum local privileges. This is only recommended for cases where script requires administrator privileges.
StartupGlobal.[bat/exe/ps1]
- StartupGlobal: script will execute as SYSTEM user at service start of Cameyo.
Cameyo allows gracefully closing applications during sudden termination events such as browser tab or window closing or connectivity loss.
It does so by sending all active windows a message WM_CLOSE followed by a WM_QUIT.
To activate this mechanism, set PowerTag !GracefulDiscoSec to the duration (in seconds) required for the application to properly quit. This duration should be between 10-15 seconds in most cases:
!GRACEFULDISCOSEC=15
You can also use a session script StartupGracefulDisco, for example:
!STARTUP_GRACEFULDISCO_PS1=...
-
!GracefulDiscoSeccorresponds to the maximum duration left for apps to be gracefully closed, knowing that PageLeave leaves the session a maximum of 20 seconds before logging it out. -
The delay between WM_CLOSE and WM_QUIT is 3 seconds by default, and can be changed using PowerTag
!GRACEFULDISCOQUITINTERVALSEC=10
Examples:
C:\ProgramData\Cameyo\StartupBefore.ps1: executes before program starts.C:\ProgramData\Cameyo\StartupBeforeSync.ps1: executes before program starts, holds session start until script ends.C:\ProgramData\Cameyo\StartupAfter.ps1: executes after program has started, right before it is shown to user.C:\Users\RemoteUser1\Cameyo\StartupAfterSync.ps1: executes after program has started, right before it is shown to user. Holds session start until script ends.
In addition to the above, you can define scripts using Cameyo's PowerTags, using this syntax:
!STARTUP_[phase][_sync]_type=...inline script...
In your inline script commands, use ^| to specify new line.
Examples:
!STARTUP_BEFORE_SYNC_BAT=@echo off^|echo %TIME% >> c:\test.log!STARTUP_BEFORE_PS1=Add-Content -Path .\DateTimeFile1.log, .\DateTimeFile2.log -Value (Get-Date) -PassThru!STARTUP_BEFORE_SYNC_PS1=Copy-Item C:\DATA\myfile.dat X:!STARTUP_GLOBAL_PS1=Write-Out "mysetting" -Path "c:\Program FIles\MyProg\settings\settings.conf"
PowerTag scripting understands special prefix commands, which must be at the script's immediate start, without spaces. Several prefixes can be combined one after the other.
Force session start
Forces session start, including splash screen removal, as soon as your script begins execution. Example:
!STARTUP_BEFORE_SYNC_PS=[!start]Copy-Item C:\DATA\myfile.dat X:
Show console window
By default Cameyo hides the script's window, which is typically a black console window. This special prefix allows you to unhide it. Example:
!STARTUP_BEFORE_SYNC_BAT=[!show]echo Hello world^|pause
Wipe out script on execution
A script marked with this tag will get wiped out once executed, leaving no traces within the user's session workspace. This is useful for scripts containing passwords or secrets that must not be visible to end-users. Example:
!STARTUP_BEFORE_PS1=[!secret]$user = "net user"^|$pass = ConvertTo-SecureString "Password123"
Cameyo also allows you to launch your program using a custom inline script by setting the config PowerTag !LAUNCHER_[type]. In this case, Cameyo will not launch your program directly but rather through the inline script you've defined, passing to it the original program path as an argument, followed by the original arguments if any.
Examples
Async time stamping inline script:
!STARTUP_BEFORE_BAT=@echo off^|echo %TIME% >> %USERPROFILE%\test.log
Automated 5 minutes session termination:
!STARTUP_BEFORE_BAT=@echo off^|timeout 300^|C:\RemoteAppPilot\RemoteAppPilot.exe -EndSession
Custom launcher 1:
!LAUNCHER_BAT=@echo off^|echo Executing %1 in a few seconds...^|timeout 5^|%1
Custom launcher 2 (asynchronous):
!LAUNCHER_BAT=@echo off^|echo Hi %USER_ID%! Now launching your program %CAMEYO_APPNAME%^|start "" "%CAMEYO_CMD%" %CAMEYO_ARGS%^|pause
This can be done by creating a Cameyo directory under ProgramData or the user's profile, and naming the script accordingly.
Example
- Create file C:\ProgramData\Cameyo\StartupBefore.bat, with one line: "
calc.exe". - Result: this script will be executed every time a session starts.
Step-by-step
- Connect to your Cameyo server as admin.
- Create on it a directory C:\ProgramData\Cameyo.
- Within this directory, create a PS1 or BAT file called StartupBefore.ps1 or StartupBefore.bat.
- This script will then execute for any Cameyo session starting on this server.
Script files can be placed in one of two locations:
%UserProfile%\Cameyo
or
%ProgramData%\Cameyo
To turn a PowerShell script into an executable:
- Open a PowerShell window (in Administrator mode).
-
Run
Install-Module ps2exe. - Run
Invoke-PS2EXE C:\ProgramData\Cameyo\StartupBefore.ps1 C:\ProgramData\Cameyo\StartupBefore.exe
Google and related marks and logos are trademarks of Google LLC. All other company and product names are trademarks of the companies with which they are associated.