How to access C:\Program Files\… path of client PC

2019-03-04 04:31发布

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?

3条回答
别忘想泡老子
2楼-- · 2019-03-04 04:47

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:

  1. Creation of link to launch TeamViewer
  2. Registering an Application to a URI Scheme
  3. How can I add a custom url handler on Windows. Like iTunes itms://
查看更多
一纸荒年 Trace。
3楼-- · 2019-03-04 04:48

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!

查看更多
Root(大扎)
4楼-- · 2019-03-04 04:53

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.

查看更多
登录 后发表回答