Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

doynton

macrumors 6502
Original poster
Oct 19, 2014
299
17
I'd like to include launching Microsoft Remote Desktop and connecting to a specific defined session using applescript. I have exported the .rdp and double clicking on it works.

How can I do this?

I've tried
Code:
set VB_Guest to "Windows"
set rdp to VB_Guest & ".rdp"
set VB_rdp to quoted form of rdp

tell application "Microsoft Remote Desktop"
	open VB_rdp
end tell
which fails with "the URL is not valid"

and
Code:
set VB_Guest to "Windows"
set rdp to VB_Guest & ".rdp"
set VB_rdp to quoted form of rdp

tell application "Finder"
	open VB_rdp
end tell
which fails with "Finder got an error: Handler can't handle objects of this class"

Is this possible?
 

superscape

macrumors 6502a
Feb 12, 2008
937
223
East Riding of Yorkshire, UK
It looks a bit like you're using guess work as to what commands to use. Have you had a look at the Microsoft Remote Desktop scripting dictionary? That's probably the best place to start. You may find that it's not scriptable at all (I'm not familiar with it, I'm afraid), or you might find the right commands to use.

If it's not scriptable then you may have some luck with UI scripting, although that's a bit clunky in my experience.
 

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
You can try :

Code:
do shell script "open /POSIX path/to/your/Windows.rdp"

Or

Code:
tell application "Finder" to open file HFS path to your Windows.rdp
(*
Specifying Paths
You can create alias objects and file objects by supplying a name specifier, where the name is the path to an item in the file system.

For alias and file specifiers, the path is an HFS path, which takes the form "disk:item:subitem:subsubitem:...:item". For example, "Hard_Disk:Applications:Mail.app" is the HFS path to the Mail application, assuming your boot drive is named "Hard_Disk".

HFS paths with a leading colon, such as ":folder:file", are resolved relative to the HFS working directory. However, their use is discouraged, because the location of the HFS working directory is unspecified, and there is no way to control it from AppleScript.

For POSIX file specifiers, the path is a POSIX path, which takes the form "/item/subitem/subsubitem/.../item". The disk name is not required for the boot disk. For example, "/Applications/Mail.app" is the POSIX path to the Mail application. You can see the POSIX path of an item in Finder in the "Where" field of its Get Info window. Despite the name, POSIX file specifiers may refer to folders or disks. Use of "~" to specify a home directory is not supported.

POSIX paths without a leading slash, such as "folder/file", are resolved relative to the POSIX working directory. This is supported, but only is useful for scripts run from the shell—the working directory is the current directory in the shell. The location of the POSIX working directory for applications is unspecified.
*)
-- or
tell application "Finder" to open file HFS path to your Windows.rdp using application file "Microsoft Remote Desktop.app" of folder "Applications" of startup disk

Info : https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/open.1.html
 
Last edited:

doynton

macrumors 6502
Original poster
Oct 19, 2014
299
17
It looks a bit like you're using guess work as to what commands to use.
Yes I am - it is my first script.

You can try :

Code:
do shell script "open /path/to/your/Windows.rdp"
Thanks. I made it like this and it starts the .rdp from my apps Resources directory and works perfectly.

Code:
set VB_Guest to "Windows"
set p2m to (path to me)'s POSIX path
set VB_rdp to quoted form of (p2m & "Contents/Resources/" & VB_Guest & ".rdp")
do shell script ("open " & VB_rdp)
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.