.NET Framework Bookmark and Share   
 index > .NET Framework Networking and Communication > how to access remort desktop through windows application using c#.
 

how to access remort desktop through windows application using c#.

how to access remort desktop through windows application using c#.
Please give solution

hiranjan1
Which area you need help in? If you need help locating a Windows API, ask in the Windows SDK forum, though I don't think there is any API for the built-in RDP client.

Not sure why you post on a .Net forum. Do you assume there is a managed class documented in Windows SDK that can be used to accessthe built-in RDP client? If there isn't any native API, there won't be a managed class either.

Please mark the post answered your question as the answer, and mark other helpful posts as helpful. This posting is provided "AS IS" with no warranties, and confers no rights.
Visual C++ MVP
Sheng Jiang 蒋晟

Simple;
Step 1) Create a blank RDP session using MSTSC and save it to your desktop.
Step 2) Open the RDP file in NOTEPAD.
Step 3) What you see are all the parms. that are contained in an RDP file.
Step 4) Copy all of these parms and put them into a Resource string in your project.
Step 5) Create an GUI application that allows you to pick the server and which shows the username to connect
Step 6)Use string.Replace(this, that) to plug the values you want.
Step 7) Save the file out as an type of RDP file (extension is "RDP"). It will have new values.
Step 8) Start a process and use that file name in the startinfo parameter of the process.
Step 9) Start the process....the operating system takes care of the rest
Here's the parms in a RDP file:
screen mode id:i:2
desktopwidth:i:640
desktopheight:i:400
session bpp:i:32
winposstr:s:0,1,97,56,1210,710
full address:s:.xxx
compression:i:1
keyboardhook:i:2
audiomode:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
displayconnectionbar:i:1
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
disable wallpaper:i:0
disable full window drag:i:0
allow desktop composition:i:1
allow font smoothing:i:1
disable menu anims:i:0
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
drivestoredirect:s:
promptcredentialonce:i:1
username:s:.yyy

AcousticGuitar
Hi,

How do I write a password say "MyPassword01" to the .rdp file (in an encypted way). Once this is done I can connect to the remote machine through Process class. But I need this get done first.

Any help is greatly appreciated.

Thanks,
Shyam B.
Samacumen
Search "password" in the terminal service forum on Technet forums web site. If you can not find answer, start a new thread there.

Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
Visual C++ MVP
Sheng Jiang 蒋晟

***** Some good TIPS to get Auto-Remote desktop work with your .Net 2.0 + frameworks... Read On...

You can either use either RDP Client or mstsc.exe to log onto remote desktops.

  1. Look up for the RdpClient.dll in your system32 folder (This wraps itself in an active X component & derives from AxHost) �Easier one �See the example of “Palantir�/strong> �Good & easy one (This needs to be done on a windows forms) on Code Project…or Just google it.
  2. The tricky one is directly logging in using mstsc directly (without typing in the username & password all the time). How do you achieve this ? Well, after quite a lot of R & D.. I came up with this.
  3. When you Run “mstsc.exe� it would pop up with a dialog, go to >>Options( Do all that you want there) & then click �strong>Save As �. it would then be stored as “Default.rdp�
  4. Open this “Default.rdp�in notepad…You would get the idea.. You are half way through .
  5. The username is stored as is.
  6. The password is encrypted using a special algorithm and stored in this RDP file as range of 1329 bits .(“Password01�or “Passowrduehw03�are going to be encrypted into the same range of 1329 bits but will differ in individual bit values.
  7. The challenge here is to encrypt it, you have to apply the same algorithm as internally must be done by remote client while making an RDP file�/span>

In the code, simply get the user details(say from a Windows forms user log on form- One time & store it in Application Settings ).. Encrypt the password by UTF8-ENCODING (Not anything else) .Save it into an RDP file, say “Remotemachine.rdp�. Start the Process, give the Process instances “StartInfo.Arguments�/span> as path to this rdp file & �/strong> StartInfo.FileName�as �systemroot%\system32\mstsc.exe� Start the Process…it would connect to the respective remote machine and decrypt the password by itself.(You have to send the encrypted bits like:

sw.WriteLine( "password 51:b:" + encyptedPasswordbits); ('sw' is the instance of File Writer Class)..

Just take care that it would not connect properly if some of the credentials are not perfect. Any queries you may post it on this forum or mail me @ shyam_b85@yahoo.co.in

Regards,
Shyam B
(Bangalore India)
www.quicksearchlinks.com (ON SALE !!)

Refer to AcousticGuitar 's forum post above on how the RDP file looks like when opened in notepad..
Password might look something like so:
password51:b:01b01010111010101010101101001001010110110101010100000001010101010101010110101010101010010111101010101011111111111111010100101
  • Edited bySamacumen Wednesday, September 16, 2009 7:03 AMNo Reason
  •  
Samacumen

You can use google to search for other answers

Custom Search

More Threads

• Sending a "struct" to an embeded CPU over the Ethernet
• HttpWebRequest certificate problem
• Control Telnet Client from Process Object
• Grabbing Friends list from Orkut
• Where Can I Download Windows SDK for Windows XP SP 2 from?
• serial communication in .net 2005
• microsoft exchange 2007 sending mail - using c# asp.net 2.0
• Networkstream & TCPClient - write does not throw IOException when server goes down.
• stream writer
• Receive mail in Bulk