Cameyo allows you to execute vbs/bat/ps1 scripts on your servers at different moments of a session's lifecycle.

Events and timing

The name portion of the script file determines its execution mode:

StartupBefore/StartupAfter[Sync].[vbs/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.[vbs/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.[vbs/bat/exe/ps1]

  • StartupGlobal: script will execute as SYSTEM user at service start of Cameyo.


If you want to run a script after an app has been closed, check out the following article: Graceful application closing


Examples:

  • C:\ProgramData\Cameyo\StartupBefore.vbs: executes before program starts.
  • C:\ProgramData\Cameyo\StartupBeforeSync.vbs: executes before program starts, holds session start until script ends.
  • C:\ProgramData\Cameyo\StartupAfter.vbs: executes after program has started, right before it is shown to user.
  • C:\Users\RemoteUser1\Cameyo\StartupAfterSync.vbs: executes after program has started, right before it is shown to user. Holds session start until script ends.


PowerTag inline scripting

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_VBS=MsgBox "Hello world. Your session will start as soon as you click OK.", vbSystemModal
  • !STARTUP_GLOBAL_PS1=Write-Out "mysetting" -Path "c:\Program FIles\MyProg\settings\settings.conf"


Special prefix commands

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.

[!start]: force session start

Forces session start, including splash screen removal, as soon as your script begins execution. Example: 

!STARTUP_BEFORE_SYNC_VBS=[!start]MsgBox "Hello world. Your session will start as soon as you click OK.", vbSystemModal

[!show]: 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

[!secret]: wipe out script upon 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"


Inline launcher substitution script

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


Example screenshots:



File-based scripting

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 VBS or BAT file called StartupBefore.vbs 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.