Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Run Remote Desktop Connection after connecting PuTTY

Posted on 2007-11-17
33
Medium Priority
?
2,484 Views
Last Modified: 2008-02-01
I currently use some VBScript to:

- launch PuTTY;
- load a stored session; and
- connect to a LINUX firewall.

Once the connection has been established after manually entering the password, I then launch a RDP (Remote Desktop Connection) which has been configured to use the Tunnel and Port specified in PuTTY, and after all of this, I am finally connected to the computer I'm trying to reach.

Here's my question:  Is there some way that I can modify the following VBScript so that once the user has entered a correct password, I would like the specified Remote Desktop Connection to automatically launch?  I want to reduce my current 2-step login process to 1-step so that I only have to enter the password once when connecting to the LINUX box, and I don't have to manually then launch RDP.  I want that second step to happen automatically.

Any help would be greatly appreciated.
Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.run ("C:\Tunnel.exe")
Do Until objShell.AppActivate("PuTTY Configuration")                               
Loop
objShell.SendKeys "{Tab}{Tab}{Tab}{Tab}" 
objShell.SendKeys "{PgDn}{PgDn}" 
objShell.SendKeys "{Enter}" 
'-----> What can I put here to launch RDP after a successful connection to the LINUX box?

Open in new window

0
Comment
Question by:DanielAttard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 12
  • 8
33 Comments
 
LVL 32

Expert Comment

by:DrDamnit
ID: 20305999
objShell.Run ("mstsc /v: " & strMachineIP & "  /console")
0
 
LVL 32

Accepted Solution

by:
DrDamnit earned 1000 total points
ID: 20306009
If you want to automatically have the password put in, you'll need to follow the steps in this article to run CryptProtectData to calculate the password. Then write that to an rdp file, then use objShell.run("mstsc " & [filename.rdp] & " /console"
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 20306011
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 32

Expert Comment

by:DrDamnit
ID: 20306020
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 20306022
How to script the terminal services client:
http://msdn2.microsoft.com/en-us/library/ms811527.aspx
0
 

Author Comment

by:DanielAttard
ID: 20306024
Thanks for the help.  Before attempting to get this working and automatically enter the password, first I will try to simply get RDP to launch.  I'll give your first suggestion a try and post back in a minute . . .
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 20306030
You may also need this hot fix to generate RDP profiles directly from mstsc with the password saved in them: http://support.microsoft.com/kb/839918
0
 

Author Comment

by:DanielAttard
ID: 20306034
OK, you're first suggestion seemed to launch the RDP immediately upon connecting to the LINUX box.  I need to wait until the user enters the password before launching RDP.

Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.run ("C:\Tunnel.exe")
Do Until objShell.AppActivate("PuTTY Configuration")                              
Loop
objShell.SendKeys "{Tab}{Tab}{Tab}{Tab}"
objShell.SendKeys "{PgDn}{PgDn}"
objShell.SendKeys "{Enter}"
'-----> need to wait here until the password is entered
objShell.Run ("mstsc /v: 192.168.999.999 /console")

0
 

Author Comment

by:DanielAttard
ID: 20306066
Before I get into the more advanced topics, is there a way to hold-off on running RDP before the LINUX password is entered manually?
0
 

Author Comment

by:DanielAttard
ID: 20306079
I want to make sure we're on the same page.  When we talk about passwords, we're talking about the one to connect to the LINUX box, not the one required for RDP, correct?

I *want* the user to be required to enter the LINUX password; but after that the RDP should launch.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306234
How they enter the password? Is that an inputbox?

regards
Chandru
0
 

Author Comment

by:DanielAttard
ID: 20306242
actually, i figured out how to enter the LINUX password automatically, now I just need to figure out how to launch a specified RDP file after the login with PuTTY.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306245
I think Damnit has already given you on hoe to opn RDP file in the post ID: 20306009.

Did you try that?
0
 

Author Comment

by:DanielAttard
ID: 20306280
I did try that, but it didn't work.  This is the line that doesn't seem to be working:

objShell.Run ("mstsc /v: 192.168.2.151 /console")

What exactly does this command try to do?
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306305
That line is trying to connect to the IP address 192.168.2.151 and directly to console of that server

Do you get any error?
0
 

Author Comment

by:DanielAttard
ID: 20306330
What does:

/v:

refer to?

why the reference to V?

I am trying to launch RDP locally, not remotely.
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 20306352
/v: tells rdp (mstsc) that this is the address you want to connect to.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306357
try this command on your machine

mstsc /?

which will give you the answer for your question.

"I am trying to launch RDP locally, not remotely."
Are you trying to connect to any server or what you are trying to achieve?

regards
Chandru
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 20306358
you said mstsc /v: 192.168.1.152 /console was not working...

Are you trying to connect to a microsoft remote desktop?
Is the firewall allowing connections on port 3389 (through all firewalls including the local machine as well as the linux firewalls on the inbetween).?
0
 

Author Comment

by:DanielAttard
ID: 20306371
Thanks for the replies again.
Yes, I am trying to connect to a microsoft remote desktop that is sitting behind the LINUX firewall.  The firewall does allow connections on port 3389.

What I am trying to do is tunnel through the LINUX box after the PuTTY connection is made.  I want to run RDP on my local machine.  I connect to localhost:10000 which is configured with the correct IP address and to use port 3389.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306382
What box you are running this script from?

RDP to you local machine - why?
0
 

Author Comment

by:DanielAttard
ID: 20306388
I must have confused you.  I want to connect to my office computer from my laptop, which is where I am now.  I want to RDP to my office WIN XP machine, which sits behind a LINUX firewall, which is configured to allow connections on port 3389.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306399
Is RDP enabled in your Windows XP machine?

Only one connection of RDP is allowed in Windows XP and when you connect on to it will automatically lock itself?

regards
Chandru
0
 

Author Comment

by:DanielAttard
ID: 20306403
Yes, RDP is enabled on the XP machine.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306411
Have you added your username to the access list for the RDP as only the domain admins and administrators will have the access by default?

When you are trying to connect to your windows XP machine do you get any error?
0
 

Author Comment

by:DanielAttard
ID: 20306445
We are very close to solving this problem for me.  This code is working when I run it separately:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "mstsc /v: localhost:10001 /console"

But when I include these lines at the end of this code:

Option Explicit
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "C:\Tunnel.exe -load OPTC -pw ~OPTC-Admin#1"
Do Until objShell.AppActivate("PuTTY Configuration")                              
Loop
objShell.Run "mstsc /v: localhost:10001 /console" ' ___Not working

Why won't this last line run when it is part of the earlier code?
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306449
Becoz of the Do Loop as the code is still looping with in that loop

Try adding the code before the loop line

regards
Chandru
0
 

Author Comment

by:DanielAttard
ID: 20306480
You got it!  That was exactly the problem.  The Do Loop was causing the focus to remain with PuTTY which for some reason seemed to prevent the MSTSC line from running.  Now it seems to be connecting fine now that I have taken out the Do Loop which wasn't needed.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306496
That's great!

Hope everything is working now

regards
Chandru
0
 
LVL 12

Assisted Solution

by:chandru_sol
chandru_sol earned 1000 total points
ID: 20306503
I would also recommend you using this

strCommand = """C:\Tunnel.exe"" -load OPTC -pw ~OPTC-Admin#1"
objShell.Run strCommand, 1, True

which will make the other line run once it is completed

regards
Chandru
0
 

Author Comment

by:DanielAttard
ID: 20306513
Thanks for the help Chandru and DrDamnit.  I really appreciate you both helping me.
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20306521
No worries! Cheers
0
 
LVL 12

Expert Comment

by:chandru_sol
ID: 20381850
Can you accept the solution?


regards
Chandru
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question