views:

497

answers:

2

So far I have:

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("""C:\Server01.rdp""")

But when I run it, nothing happens. Is it even possible to run an RDP file with VBScript? If so, then what am I doing wrong?

A: 

I think you need to run mstsc.exe and pass the rdp file in as an argument.

http://technet.microsoft.com/en-us/library/cc753907%28WS.10%29.aspx

duckworth
I'm a bit of a novice with VBScript, could you explain in more detail, perhaps with some code.
wahle509
That link refers to the command line, how can I do that with a script?
wahle509
+1  A: 

try calling mstsc.exe with the .rdp file name passed in:

objShell.Run(""mstsc C:\server01.rdp"")
Josh E
No, I get "The system cannot find the specified file".
wahle509
you'll need to make sure that your environment path variables point correctly (if you can do start-> run -> mstsc c:\server01.rdp then you should be ok on this). Also check the quotation marks on my answer - I didn't include the extra one that you originally had!
Josh E
As a side thought, you could use a batch file instead of VBScript if you want, since this is a relatively simple operation.
Josh E
I'm getting "Invalid connection file" when trying to run it. Why's that? I'm sure the path is correct.
wahle509
Could I run the batch file using a VBScript?
wahle509
so the file C:\Server01.rdp exists, and you can run it manually using the start -> run method described above? If so, then the vbscript you posted should work. To address your second comment, you can create a batch file by opening notepad and typing: mstsc C:\server01.rdp, then saving the file as myBatch.bat
Josh E
Got it! objShell.Run "mstsc.exe server01.rdp" Thanks for the help!
wahle509
no problem. glad to help :)
Josh E