Thought I’d share this in case anyone else wants to do this. Plus, maybe there’s a better way? I just purchased RoyalTS, so I’m still learning.
I use buttons on my mouse to switch between virtual desktops. When RDP is in full screen mode, you have to do a special key combination (CTRL+ALT+HOME then CTRL+ALT+Left / Right)
So I have two buttons, one to go left, one to go right.
I wanted to make my connection go full screen with windows key passthrough on separate virtual desktops.
So I made a powershell script to accomplish this workflow. It takes two parameters:
desktopname and remove
desktopname is the name of the virtual desktop, to which I pass $Name%
remove is boolean, $true or $false
So you take the powershell script, and make two command tasks, one to open the virtual desktop and switch to it, the other to close it
You set the tasks on the connection or the folder, wait it to complete before connecting. When you open a connection, powershell creates a virtual desktop with the connection name, switches to it, the returns to RoyalTS, which opens full screen.
When you disconnect, powershell removes the virtual desktop with the connection name.
It’s not perfect, but it works well enough for me - and could probably be improved.
In the task, the command is the path to pwsh.exe on your machine. The working folder is the path to where you put the powershell script.
Arguments looks something like this:
(to open)
-WindowStyle Hidden -NoProfile -Command .\rtsVirtDesktop.ps1 -desktopname '$Name$'
(to close)
-WindowStyle Hidden -NoProfile -Command .\rtsVirtDesktop.ps1 -desktopname '$Name$' -remove $true
Note the quotes around $Name$, to handle spaces in connection name.
WindowStyle Hidden is ignored because RoyalTS opens a window anyway to run this. Not an issue.
The script is as follows:
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$false)]
[System.String]
$desktopname="Desktop",
[Parameter(Mandatory=$false, Position=1)] [string] $remove='false'
)
Import-Module -Name VirtualDesktop
if ($remove -eq $true)
{
Remove-Desktop "$desktopname"
}
else
{
New-Desktop | Switch-Desktop | Set-DesktopName -Name "$desktopname"
}