I have an Asp.NET web application. I can call and run Teamviewer in my application when running on local.
I have a class for call and run TeamViewer.
class CallTeamViewer {
public static string TeamViewerPath = "";
public static void FindTeamViewerPath () {
if (File.Exists(@"C:\Program Files\TeamViewer\Version7\teamviewer.exe")) {
TeamViewerPath = @"C:\Program Files\TeamViewer\Version7\teamviewer.exe";
}
if (File.Exists(@"C:\PROGRAM FILES (X86)\TeamViewer\Version8\teamviewer.exe")){
TeamViewerPath = @"C:\PROGRAM FILES (X86)\TeamViewer\Version8\teamviewer.exe";
}
}
public static void ConnectAndRunTeamViewer(string TamViewerId, string TeamViewerPass) {
CallTeamViewer.FindTeamViewerPath();
if(TeamViewerPath.Length > 0) {
string parameter;
parameter = " -i " + TamViewerId+ " --Password " + TeamViewerPass+ "";
System.Diagnostics.Process.Start(TeamViewerPath,parameter);
}
}
}
I have 2 textboxes and 1 button on aspx page
Connect.aspx.cs
protected void btnConnect_Click(object sender, EventArgs e) {
CallTeamViewer.ConnectAndRunTeamViewer(txtTeamviewerID.Text,txtTeamviewerPass.Text);
}
This class works on local. It can find the path of Teamviewer in my computer.
My question: How can I change my class to find path of Teamviewer of client user?
There seems to be misunderstanding of how web works :) You need to run something on client side - not on server side. ASP.NET executes just on server side (and passes back just html markup that is interpreted by browser). For this kind of work you need a thick client - see @Damien_The_Unbeliever comment regarding security - LOL btw. Since you're already in .NET world, I recommend using ClickOnce (.NET technology that allows you to install applications from web url with just one click - provided your clients have .NET framework installed) and make small app that will do the "thick client" job for you.
This is possible, but you still need to run an executable or a .reg file on the client's machine to register a protocol handler.
Those kinds of applications (e.g., uTorrent and magnet links, etc), usually define a URI scheme and register a protocol handler on the client's computer.
For example, this is a sample URI for a magnet link:
magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C
Then, your ASP.NET application can redirect the user to a URI like that, and the OS will notice that there's a protocol associated to that URI and ask the user if he wants to launch that application.
See:
I would make some settings page for the user, that she/he could add a path of TeamViewer into the cookies/database. Hope it helps!
来源:https://stackoverflow.com/questions/24327664/how-to-access-c-program-files-path-of-client-pc-in-asp-net-c