473,405 Members | 2,373 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,405 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 34153
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.