Click here to Skip to main content
15,920,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I need a help to connect remote desktop and from there i need to click notepad exe and type the variables passed from my code(As Key stroke). Please let me know your suggestion any sample for those to automate the rdc process which was helpful to me.

The below code for connecting rdc:
C#
Process rdcProcess = new Process();
           rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\cmdkey.exe");
           rdcProcess.StartInfo.Arguments = "/generic:omh/rdcipaddress /user:" + "Vishnus + " /pass:" + "Password";
           rdcProcess.Start();

           rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
           rdcProcess.StartInfo.Arguments = "/v " + "rdcipaddress"; // ip or name of computer to connect
           rdcProcess.Start();
Posted
Updated 16-Jun-13 22:33pm
v3

1 solution

Hello Vishnu,

Using an RDP connection file you can set the alternate shell to be your application, and you pass that as a command-line argument to mstsc.exe. the typical rdp file syntax is like
screen mode id:i:2
desktopwidth:i:1280
desktopheight:i:1024
session bpp:i:16
winposstr:s:0,1,0,0,1280,819
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
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
full address:s:srv001.mycompany.com
audiomode:i:0
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:C:\Windows\Notepad.exe
shell working directory:s:C:\
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
drivestoredirect:s:I:;

For example lets say your connection file name is withNotepad.rdp and it is stored in C:\RDPCONS then you run
mstsc.exe C:\RDPCONS\withNotepad.rdp

Note :- Please note that when such a program is closed on remote desktop then you won't be able to access the regular explorer shell.

Regards,
 
Share this answer
 
v2
Comments
visnumca123 14-Jun-13 6:19am    
Hi Prasad,

I'm Very happy for your reply & thanks for your reply! But my query is regarding rdc open and sending system keystrokes to open EXE in RDC system and put varaible what i passed like the notepad is there i need to fill that notepad and save that in RDC system using c# please help!!!.
libin0410 18-May-15 4:49am    
have you resolved the problem ? i am working to resolve other problems and i find other website which will help you : https://www.nccgroup.trust/en/blog/2015/02/violating-the-virtual-channel-rdp-testing/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900