Launching an AVD Published App Via Command Line

We are experimenting with Azure Virtual Desktop and I have a need to launch a published application from a command line.  I haven’t found much documentation on that, and perhaps that is because I don’t know where to look.

However, I did find out a few things that might help me.  Everyone who has the MSRDC.exe client installed, and has logged into their feed, has rdp files for all their apps.  The RDP files are located in C:\Users\<username> AppData\Local\rdclientwpf\

Screenshot 2023-06-20 060408

In that folder, you will see a folder for each subscription you have, plus a connectionsettings.store folder and a subscription json file.

If you look in the uniquely named folders, you will see and ico, a png, and a rdp file for each application in that Workspace.  While the folder names are unique per installed instance, the name for the 3 files is consistent across the environment.  This means if you log into the the remote desktop client on 3 different machines, the folder names are different, but the files inside are identical.  This is true even if different users sign into the workspace.

Screenshot 2023-06-20 060041

This doesn’t exactly tell you how to launch it via a command line though.  So, for my particular use case, I need to be able to launch a published app as a response to an trigger.  But I don’t know where the file is for each user. 

I could potentially create a copy of the rdp file and deploy that to a known location.  As long as the user has access to the published app that should work.  Or I can record the RDP name and then go look for it.  Here is a PowerShell script to do that:

$rdpFileName = “<GUID for the app>.rdp”
$searchpath = “$($env:USERPROFILE)\AppData\Local\rdclientwpf”
$content = Get-ChildItem $searchpath
Foreach ($item in $content) {
     If ($item.Mode -eq “d—–“){ 
         $gci = Get-ChildItem $item.FullName
         foreach ($_ in $gci) {
             If ($_.name -eq $rdpFileName){
                 # Write-Host “Full Path is $($_.FullName)”
                 $launchpath = $_.FullName
             }
         }
     }
}
& ‘C:\Program Files\Remote Desktop\msrdc.exe’ $launchpath /u:$($env:username)@<YourUsersDomain>

In the script, enter the guid filename for your app.  (Note: You will have to go find it manually the first time.)  You also need to enter the domain for the login.  If you clear out the username parameter (/u:…), you will be prompted to login to the Workspace each time you launch the app.  There are some other parameters you can set.  At the time of this writing, there wasn’t good documentation for them, and I didn’t find them useful.

Leave a Reply