473,326 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Remote Desktop Connection from c#

Hi,

Is there a way to launch an remote desktop connection to a specified
server/username from c#?

If there's a way to send the password too that would be useful, but i'm
not so interested in that if its a problem.

Thanks!
Andrew

Jul 28 '06 #1
8 34118
you could probably run process.start against the mstsc.exe program (remote
connection manager) to shell an instance of Remote Conenction Manager to
create your connection using a .rdp file as your command line argument.
You'll need to dig about for the correct argument syntax but can start here:

http://technet2.microsoft.com/Window...e--RegardsJohn Timney (MVP)<tr******@hotmail.comwrote in messagenews:11**********************@i42g2000cwa.g ooglegroups.com...Hi,>Is there a way to launch an remote desktop connection to a specifiedserver/username from c#?>If there's a way to send the password too that would be useful, but i'mnot so interested in that if its a problem.>Thanks!>>Andrew>

Jul 28 '06 #2
John Timney (MVP) wrote:
you could probably run process.start against the mstsc.exe program (remote
connection manager) to shell an instance of Remote Conenction Manager to
create your connection using a .rdp file as your command line argument.

Cool, thanks alot thats exactly what I needed.
Having tried this however a problem has emerged;

When i run the application from a networked location i get a
SecurityException :(

What can i do about this?

Thanks!

Andrew

Below is the top of the stack trace
System.Security.SecurityException: Request failed.
at
System.Security.CodeAccessSecurityEngine.ThrowSecu rityException(Assembly
asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle
rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at
System.Security.CodeAccessSecurityEngine.ThrowSecu rityException(Object
assemblyOrString, PermissionSet granted, PermissionSet refused,
RuntimeMethodHandle rmh, SecurityAction action, Object demand,
IPermission permThatFailed)
at
System.Security.CodeAccessSecurityEngine.CheckSetH elper(PermissionSet
grants, PermissionSet refused, PermissionSet demands,
RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction
action, Boolean throwException)
at
System.Security.CodeAccessSecurityEngine.CheckSetH elper(CompressedStack
cs, PermissionSet grants, PermissionSet refused, PermissionSet demands,
RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
at Form1.menuItemClicked_RDC(Object sender, EventArgs e)

The action that failed was: LinkDemand
The type of the first permission that failed was:
System.Security.PermissionSet
The Zone of the assembly that failed was: Intranet

Jul 28 '06 #3
Code executed from remote locations is run (by default) at a different trust
level. You need to tell your PC(s) to trust the code enough to run the
Process.Start command; in 1.1 you can assign trust using caspol.exe, or the
..net configuration utility (start menu), and you can assign trust via e.g.
the network path, the SNK, etc... alternatively, in 2.0 you can use a
ClickOnce manifest signed with a code-signing cetificate that is in the
user's certificate trust chain - you can then assign the trust in the
deployment package.

Marc
Jul 28 '06 #4
If you like, there is RDP ActiveX control that you can use in C# project.
It has good functionality, lots of events, it supports virtual channels and
you can personalize it almost as you like.
There is not a lot of documentation but the component is quite self
documenting.
Some documentation is here:

http://msdn.microsoft.com/library/de...interfaces.asp

<tr******@hotmail.comha scritto nel messaggio
news:11**********************@i42g2000cwa.googlegr oups.com...
Hi,

Is there a way to launch an remote desktop connection to a specified
server/username from c#?

If there's a way to send the password too that would be useful, but i'm
not so interested in that if its a problem.

Thanks!
Andrew

Jul 28 '06 #5
(clarification; the 1.1 options also apply in 2.0 - but the ClickOnce route
is simpler as you don't need to make policy changes on each client)

Marc
Jul 28 '06 #6

Marc Gravell wrote:
Code executed from remote locations is run (by default) at a different trust
level. You need to tell your PC(s) to trust the code enough to run the
Process.Start command; in 1.1 you can assign trust using caspol.exe, or the
.net configuration utility (start menu), and you can assign trust via e.g.
the network path, the SNK, etc... alternatively, in 2.0 you can use a
ClickOnce manifest signed with a code-signing cetificate that is in the
user's certificate trust chain - you can then assign the trust in the
deployment package.

Marc

Cool, Thanks!

I've been reading up about this ClickOnce business but I'm a bit
confused by some of it.

Do I have to use an installer to setup all this trust business?

I just want to be able to distribute the app as an exe. Nice and simple
:)
Andrew

Jul 28 '06 #7
Do I have to use an installer...

Nope; with both online-only and installed ClickOnce deployments, your app
(when published) gets wrapped in a ".application" file; users execute the
".application", which deals with all the fun of "is it already installed?
does it need to be? is it the current version? do I trust it? has someone
tampered with the files?" questions... all the user sees (the first time) is
"wanna run this?" [paraphrased] (subsequent executes are silent). More
importantly, because it is system-managed, even a non-administrator on a
locke-down PC can install (if offline mode is enabled) the app into their
start menu. Handy.

In VS2005, look at the project properties, on the "Publish" and "Security"
tabs; the latter allows you to determine the trust settings, the former
allows you to generate the manifest (and supporting files); note that you
can publish directly to a UNC to support your network usage.

Marc
Jul 28 '06 #8
Hello All,

Let me know if there is any way that I connect to remote desktop from
command line or any other utility. I would need the command to log off
the session as wel..
Though mstsc.exe /v: is available i should hav manual intervention to
enter the credentials..

Also let me know how we can do it through any of c# classes.
Sample code will be of great help!!!

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Aug 8 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Elp | last post by:
Hi, I have developped a Windows applcation (in C#) that allows, among other things, users to view and control the desktop of a remote Windows XP Pro machine. I have actually simply embedded the...
1
by: vighnesh | last post by:
Hi All I am dealing a project in ASP.NET in which I have to establish a connection to SQL Server 2000 database,where the database was located on a remote system. For this I have used...
1
by: anonieko | last post by:
Problem When Remote Desktop to my main office machine, and when trying to connect to SQL Express, I was becoming increasingly frustrated with the following error: Error: 'Failed to generate a...
15
by: =?Utf-8?B?TVNU?= | last post by:
To demonstrate my problem, I have a very simple VB Windows application. It has a text box that is used to display a counter, a button to reset the counter, and a timer that increments the counter...
3
by: mac420 | last post by:
I want to implement remote desktop connection in C#.net same as Program->Accessories->Communications->Remote Desktop Connection can anybody plz help me Thanx in advance
2
by: CLM | last post by:
When I test the remote access at work (lapttop computer to desk top computer) the connection works fine. When I bring the laptop home and try to connect to my desktop I get the error msg: The...
4
by: chris | last post by:
Hi guys I have a Frontend and Backend DB that works well on my LAN. I use a INI file Path, to access a mapped network connection back to the Backend Data file. Path=F:\Server\Data.mdb I...
12
by: sakthikumarb | last post by:
Hi , I need to monitor for Remote desktop connection is made for a particular host. There is any WMI event ?.if not how can monitor for remote desktop connection.. (Basically i need to generate...
0
by: Andy | last post by:
Hello all, I have a user using Remote Desktop connection, who is getting an error when trying to print. When my program starts, he get's an error 2205, the default printer isn't set up...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.