473,748 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 34290
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.comwrot e in messagenews:11* *************** ******@i42g2000 cwa.googlegroup s.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
SecurityExcepti on :(

What can i do about this?

Thanks!

Andrew

Below is the top of the stack trace
System.Security .SecurityExcept ion: Request failed.
at
System.Security .CodeAccessSecu rityEngine.Thro wSecurityExcept ion(Assembly
asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHa ndle
rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at
System.Security .CodeAccessSecu rityEngine.Thro wSecurityExcept ion(Object
assemblyOrStrin g, PermissionSet granted, PermissionSet refused,
RuntimeMethodHa ndle rmh, SecurityAction action, Object demand,
IPermission permThatFailed)
at
System.Security .CodeAccessSecu rityEngine.Chec kSetHelper(Perm issionSet
grants, PermissionSet refused, PermissionSet demands,
RuntimeMethodHa ndle rmh, Object assemblyOrStrin g, SecurityAction
action, Boolean throwException)
at
System.Security .CodeAccessSecu rityEngine.Chec kSetHelper(Comp ressedStack
cs, PermissionSet grants, PermissionSet refused, PermissionSet demands,
RuntimeMethodHa ndle rmh, Assembly asm, SecurityAction action)
at Form1.menuItemC licked_RDC(Obje ct 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******@hotma il.comha scritto nel messaggio
news:11******** **************@ i42g2000cwa.goo glegroups.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 ".applicati on" file; users execute the
".applicati on", 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
6375
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 Remote Desktop ActiveX control in my C# app and this works fine. However i have now a new requirement for my app: multiple users have to be able to view and control the same remote desktop simultaneously using my application. Big problem:...
1
2295
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 SQLConnection object and specified the connetion string.But when it comes to establish a connection its giving me the Error that I. Connection string : workstation id=localhost;packet size=4096;user
1
4984
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 user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.'
15
7084
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 every second. I remote desktop to the computer hosting this application and run the application. It starts up and displays the counter incrementing every second. If I disconnect the network cable between the two computers for 10 seconds and...
3
5162
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
2479
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 client could not connect to the remote computer. Remote connections might not be enabled or the computer might be too busy to accept new connections. It is also possible that network problems are preventing your connection. Please try your connection...
4
5310
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 have a situation now that requires a Remote Connection with my
12
9796
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 a event from remote host that connection is made by xxx user ...) Thanks in advance.. -Sakthi
0
2268
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 correctly. Then when he tries to preview a report, he gets an error 9: subscript out of range. Anyone have any ideas on this? Thanks!
0
8831
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8244
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.