Double Click Local Files to Open In RemoteApp (Remote Desktop)

Double Click Local Files to Open In RemoteApp (Remote Desktop)

Remote Desktop

RemoteApp or Published Applications, in Microsoft Remote Desktop Server is a really cool feature. It allows you to publish an application from a Remote Desktop Server (Terminal Server for the more old school among us) and have it either installed (Server 2008 R2 only) or published via a .RDP file (2008-2012R2). Basically, in short, this allows a user to have an application, like Microsoft Word or Notepadd++ for example show in their local start menu or as an icon which they can click, thus opening the application. To the user, the application appears to be on their local machine (it doesn’t open an entire Remote Desktop – just the app, which appears to be on the local PC) but in reality, it’s running on the Remote Desktop Server.

Aside from this being quite nice, a common question I get from users of RemoteApp or published applications in Microsoft Remote Desktop Server is “why can’t I double click a file on my desktop and have it open this application”. Explaining to the user that the application isn’t really on their machine or asking them to open the app, then browse back to \\tsclient is too hard.

So how about instead we hack the registry to just let them do what they want?

Please Note: there’s a couple of minor security issues this raises, which I will discuss in detail, below. You need to read them and decide if they effect or concern you. In most cases of businesses, for internal use, where trusted users are accessing properly configured systems, which already have appropriate permissions in place, this won’t be a concern but you need to read them and decide if they apply to you.

Assuming you already know how to set up RemoteApp publishing, let’s begin. I’m doing this on 2008 R2 because I’m making the assumption more people are still using that than 2012 (personally, I prefer 2012 R2 server immensely but that’s by the by).

Step 1: Publish Your Application

Ok, so assuming you have RemoteApp already to go, certificates in place (if you use them), website configured and everything is working, let’s publish our app.1

Pick your application. In my case, I’m going to pick the accounting package “MYOB” because I don’t have it on my local PC and I don’t actually use it, so it’s a good test case for this demo.

2

Click finish. Great. Now we’ve got out remotely published application.

Step 2: Allow Command Line Arguments

Next up we want to create the .RDP file that end users can double click to automatically run our application in Remote Desktop, from their local PC.

First up, however, we need to allow the end user to run command line arguments against our published application. Microsoft will warn you this is a security risk and, depending on your scenario, it could be. It’s not likely to be an additional risk for 95% of people, however. Here’s why:

What makes this is a “risk” is that users could theoretically append any command line they like – for example “/uninstall”. So if they have permission to uninstall the app, they could uninstall it, remotely. In 99% of cases, however, the end user could just as easily (easier in fact) just log on to the Remote Desktop Server as a desktop and perform this act – and few places would allow normal users to uninstall apps on a terminal server. 

None the less, bear this in mind. If the application you’re publishing allows command line switches to do funny things like “/disableallsecurity” or “/disablecorporateplugins” and you don’t want users doing this – and you don’t allow them to interact with the desktop (where they could just do this anyway), then this might not be for you.

So let’s enable command line arguments. Right click on the application and pick properties:

3

Now just allow the user to run command-line arguments – I’m going to allow any because it adds no security changes to my existing instance (users are normal privs and have full desktop access, anyway – we trust our staff).

4

Step 3: Create .RDP File

Now right click on the application again and pick “Create .rdp File”. Basically, you just do this like normal. Then we’re going to edit the file that gets created.

5

Then just save the .RDP file to your normal location.

6

Now we need to open this file in your preferred text editor and make two small changes. Here’s how the file looks. The circled areas in red are what we’re going to change:

7

We need to add the character: * at the end of the first line, changing it from:

remoteapplicationcmdline:s:

to

remoteapplicationcmdline:s:*

So now we can execute command line arguments against the .rdp file. The other thing we need to is completely remove the last line:

signature:s:AQABAAEAAA....(etc)

That’s because the .rdp file size has now changed, so this hash won’t match. If you want to recalculate the hash manually by all means feel free but for the sake of this tutorial, I’m not going to.

Step 4: Configure the Client PC File Association

So technically, that’s enough to allow a client to do what we need them to do. Now all we need to do is associate the client file type with our .rpd file and the user will be able to double click a local file and have it stream the contents to the Remote Desktop Server, where the application will handle the job.

Here’s the registry changes we need to make, in the form of a single, easy to edit .reg file.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\MYOB.19]
"AppUserModelId"="Microsoft.Windows.RemoteDesktop"
"EditFlags"=dword:00100000

[HKEY_CURRENT_USER\Software\Classes\MYOB.19\shell]

[HKEY_CURRENT_USER\Software\Classes\MYOB.19\DefaultIcon]
@="C:\\Users\\Public\\Documents\\RemotePackages\\Myob.ico,0"

[HKEY_CURRENT_USER\Software\Classes\MYOB.19\shell\open]

[HKEY_CURRENT_USER\Software\Classes\MYOB.19\shell\open\command]
@="\"mstsc.exe\" /REMOTEFILE:\"%1\" \"C:\\Users\\Public\\Documents\\RemotePackages\\myobp.rdp\""

[HKEY_CURRENT_USER\Software\Classes\.myo]
@="MYOB.19"

[HKEY_CURRENT_USER\Software\Classes\.myo\MYOB.19]

[HKEY_CURRENT_USER\Software\Classes\.myox]
@="MYOB.19"

[HKEY_CURRENT_USER\Software\Classes\.myox\MYOB.19]

(Please note, some of the above may be damaged by website formatting, so paste it into Notepad to check the correct syntax, if you’re going to use it. I think the line ending in “RemotePackages\\myobp.rdp” gets cut off in the view above but you can see it if you paste it into notepad).

Step 5: We’re Done!

That’s the registry file. Save that as something.reg and double click it, on your PC and you will now be able to open local files on your RDS, from a double click.

A little explanation of the above registry file:

[HKEY_CURRENT_USER\Software\Classes\MYOB.19]

The MYOB.19 bit is a name I made up. It doesn’t matter what it is – it just has to be unique and common the whole way through your file.

[HKEY_CURRENT_USER\Software\Classes\MYOB.19\DefaultIcon]
@="C:\\Users\\Public\\Documents\\RemotePackages\\Myob.ico,0"

I copied the MYOB icon to my local machine, so the local MYOB files have the right icon associated in Windows Explorer. This registry key handles that association.

[HKEY_CURRENT_USER\Software\Classes\.myo]
@="MYOB.19"

[HKEY_CURRENT_USER\Software\Classes\.myo\MYOB.19]

.myo and .myox are the file types for MYOB. You just repeat those two lines for each file type you require (so for MS Word, you’d need .doc, .docx, .rtf, .dot, etc. etc.)

So does it work?

Let’s test it. I have a sample file on my desktop called “tutorial.myo”. When I double click it, here’s what I see:

First, it spawns the connection for about a second:

8

Then MYOB is open and asking for my password.

9

So there you have it. I can now run completely utilise my remote application, on my local file system, with no installation footprint other than a text file with a few lines it in about a hand full of registry entries.

Where is this useful?

Primarily where your remote server and local PC are either connected by fast networking or the file sizes are small. In the case of a local area network, this is particularly useful for provisioning various applications to users where it’s either difficult to install the app on a PC by PC basis, licensing makes it hard (i.e. a dongle – although check your license conditions in this case) or you want to maintain more control over who is using what applications (i.e. a limited number of concurrent users, etc).

As always, give me feedback below, let me know if I forgot anything and if you want a batch file to do  the entire thing to to a PCs, I’ll put it in the below.

One Click Install

The batch file below, when clicked, will update the registry and copy the .rdp file from a central location to the client’s PC. It uses a VBScript file (to check that all the paths exists and then copy the file if it can be found, to avoid errors) and then updates the registry with the stuff from Step 5.

cscript \\fileserver\share\myob.vbs
\\fileserver\share\myob.reg

Here’s the referenced VBScript

'Check that folder exists. If not, create it.
Set fso = CreateObject("Scripting.FileSystemObject")
Set shl = CreateObject("WScript.Shell")
path="c:\users\public\documents\remotepackages" 'path to folder
exists = fso.FolderExists(path)

if (exists) then
'Do you need to do anything here?
else
fso.createfolder("c:\users\public\documents\remotepackages")
end if

Const SourceFile = "\\fileserver\share\myob.rdp"
Const DestinationFile = "c:\users\public\documents\remotepackages\myob.rdp"

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(DestinationFile) Then
If Not fso.GetFile(DestinationFile).Attributes And 1 Then
fso.CopyFile SourceFile, "c:\users\public\documents\remotepackages\", True
Else
fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes - 1
fso.CopyFile SourceFile, "c:\users\public\documents\remotepackages\", True
fso.GetFile(DestinationFile).Attributes = fso.GetFile(DestinationFile).Attributes + 1
End If
Else
fso.CopyFile SourceFile, "c:\users\public\documents\remotepackages\", True
End If
Set fso = Nothing

Finally, the referenced file myob.reg, is the reg key above in Step 5. As with the reg file, a couple of the longer lines in the VBScript get cut off in the web viewer so paste it into Notepad to view the whole thing.

About the Author

Rodney

I’m a veteran of way too many years of IT (although I still love it) and I currently head up the techincal work over at Host One (major sponsor of this site), where I’m also a partner. Feel free to ask me anything about Cloud Computing and I’ll try to be helpful, in a non-salesy kind of way.

View all posts by Rodney →

  1. David ChernyDavid Cherny01-11-2015

    Awesome article thanks

  2. NeadomNeadom02-28-2015

    Nice Article can you do this same with 2012r2? I have tried this but I am not sure my registry entries are the same.

    Enviornment is:
    Desktop is 2012R2 Server Connecting to Remote Apps from another 2012R2 Server. Can you show a screen shot of what your registry entries look like fully expanded.

    Let me know.

    • RodneyRodney03-08-2015

      Hi Neadom – yes, this should work with 2012 R2. The concept is the same – the registry entries are on the client, not the server, and all they’re doing is associating file types with an “application” (in this case, the application is the remote desktop .rdp file).

      My testing client is Windows 8.1, which should have the same registry values as 2012 R2, as they’re basically the same core OS (but also the same keys will work from XP and up).

  3. AndriAndri04-14-2015

    Do you know if it´s possible to set a parameter in the .rdp file so that it will open að specific file with the remote app? E.g. if you have a Excel remoteapp the .rdp file would open a specific .xlsx file located on the terminal server.

    Best regards,
    Andri

    • RodneyRodney04-14-2015

      While that goes completely against the point of double clicking a local file to open it, yes, it is possible to make RDP automatically perform a task on a user log in.

      Assuming RemoteApp is configured (and it would need to be for the above article to work), then in the .rdp file you simple include:

      remoteapplicationprogram:s:||excel_file.xlsx

      And that would open the file. In my example above, I have defined the value of the file to “*” (i.e. anything) but by hard coding it to a specific file name, it will always open that file. So even if the user double clicks a local file of a different file, it would still open excel_file.xlsx. Why you’d want to do that, other than to mess with people, I couldn’t say. I suspect you want users of a system to always just go to the one thing they should be working on (i.e. a timesheet xls file)?

      You could of course just release a .rdp file that always opens the same target – however I see problems with this approach. Firstly, users are extremely likely to simple “x” (close) out of the RDP session, thus leaving the file perpetually open and therefore locked to other users.

      Likewise, nothing (in the above approach) stops them closing the file but leaving remote Excel open and browsing the remote file system to other files, so it’s not a security measure (or shouldn’t be used as one).

      I see what you’re trying to do but I think, unless each user has their own file, you’re going to find users never properly close the file a real issue.

  4. AndriAndri04-14-2015

    Thanks for your reply.

    The objective is to make it as simple as possible for users to open a specifc excel file. The file is a dashboard connected to OLAP cubes on another server in Azure. Access is only given through an Excel RemoteApp on terminal server in Azure. I tried to add the excel file like so: remoteapplicationprogram:s:||”C:\Users\Test\Documents\Dashboard,xlsx” but it says that Excel 2013 is not in the list of authorized programs, even though using remoteapplicationprogram:s:||EXCEL works.

    Since the RDP session is only through the Excel RemoteApp, how would the user be able to close the RDP session without closing the Excel file itself since when they click the (x) of the Excel RemoteApp the file and the session would close thus not leaving the file open and locked.

    Another option that’s probably more in line with this article would be to have the file locally on each users computer and create a shortcut to open the file with the Excel RemoteApp. Do you know if that’s possible without associate every Excel file with the RemoteApp since the users would use their own local Excel for other files?

    Best regards,
    Andri

  5. Mike TMike T01-29-2016

    Do you have an updated article that you have posted to do the same for a Windows 2012 R2 RDS server?

    • RodneyRodney01-29-2016

      Sorry no. I’ll look at adding it soon however the steps are basically the same.

  6. SeanSean08-17-2016

    hi all,

    im trying to what is described with MS Project 2016 on RDS 2012, but i get an error:

    RemoteApp Error
    Couldn’t open this program or file. Either there was a problem with Project 2016 or the file you’re trying to open couldn’t be accessed.
    For assistance, contact your system administrator.

    this is the reg file i made – its basically the same as yours:

    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\Software\Classes\MSProject.Project.9]
    “AppUserModelId”=”Microsoft.Windows.RemoteDesktop”
    “EditFlags”=dword:00100000

    [HKEY_CURRENT_USER\Software\Classes\MSProject.Project.9\shell]

    [HKEY_CURRENT_USER\Software\Classes\MSProject.Project.9\DefaultIcon]
    @=”C:\\Users\\Public\\Documents\\RemotePackages\\WINPROJ.ico,0″

    [HKEY_CURRENT_USER\Software\Classes\MSProject.Project.9\shell]

    [HKEY_CURRENT_USER\Software\Classes\MSProject.Project.9\shell\open]

    [HKEY_CURRENT_USER\Software\Classes\MSProject.Project.9a\shell\open\command]
    @=”\”mstsc.exe\” /REMOTEFILE:\”%1\” \”C:\\Users\\Public\\Documents\\RemotePackages\\WINPROJ.rdp\””

    [HKEY_CURRENT_USER\Software\Classes\.mpp]
    @=”MSProject.Project.9″

    [HKEY_CURRENT_USER\Software\Classes\.mpp\MSProject.Project.9]

    btw, the RemoteApp by itself works perfectly.

    anyone managed to get this to work on RDS 2012 R2?

    thanks and you have a brilliant mind to think of this workaround!!!

    Sean.

  7. SeanSean08-21-2016

    Hi, a short followup on this issue on RDS 2012 R2.

    file associations works with the following config if you have win 8.1 and above:

    GPO settings:
    1. user config > Policies > Admin Temp > Windows Components > Remote Desktop Services > RemoteApp and Desktop Connections > Specify default connection URL
    value: https://my_rds_web_portal.com/rdweb/feed/webfeed.aspx – change according to your portal’s address.
    2. computer config > Policies > Admin Temp > Windows Components > Remote Desktop Services > Device and Resource Redirection > Do not allow drive redirection
    value: disabled – this is a must or you wont be able to open local files with remoteapp.

    Thats it. hope this helps someone

    Sean.

  8. ThomasTranThomasTran10-25-2016

    I make a better solution with the freeware RemoteApp Express. With this program there is no need for making any File Type Associations on the local side. Just with a right click on the document file and choose Open with RemoteApp Express then the file will be opened with the default associate prograrm on the server side.

    RemoteApp Express is the opposite redirect with Remote File Transfer – host server-to-client (or Remote Executer depending the use), it’s client-to-host redirection

  9. AndreAndre01-04-2017

    my company was wanting NAIC Business Entity Insurance License Registration Form some time ago and found a website with 6 million forms . If others need to fill out NAIC Business Entity Insurance License Registration Form also , here’s a https://goo.gl/1PAUOp

  10. joeyjoey03-16-2017

    Interesting, but one question. is it possible to have this work in the opposite way. e.g. A user is running outlook remoteapp, and clicks a hyperlink in an email. currently, outlook launches edge browser as a remoteapp and opens that link in the remote browser window. Would it be possible to have the link open from the remote Outlook app, in a local Edge or IE browser window?

    • RodneyRodney03-21-2017

      Almost impossible, I’m afraid, unless you also set the local PC as an RDS server and repeated the steps above, in reverse. Essentially, there’s no way to call a local application from the RDS server, with a single click, I’m afraid.

    • ThomasTranThomasTran07-13-2017

      Yes, you can use Remote Executer to redirect URL from server to local browser

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.