Click here to Skip to main content
13,703,265 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
hello all

unable to open process or application path after i publish my asp.net web application using c# code
Access is denied

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ComponentModel.Win32Exception: Access is denied

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[Win32Exception (0x80004005): Access is denied]
   System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited) +6565246
   System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited) +93
   System.Diagnostics.Process.Kill() +46


What I have tried:

this is my code :

protected void btnTeamViewer_Click(object sender, ImageClickEventArgs e)
       {
           foreach (Process proc in Process.GetProcessesByName("TeamViewer"))
           {
               proc.Kill();
           }


           string Path = "";
           //PartnerIP = "-i 8.8.8.8 --Password test";
           string curFile = @"C:\Program Files\TeamViewer\Version7\TeamViewer.exe"; // 32bit
           //string curFile = @"C:\Program Files (x86)\TeamViewer\Version9\TeamViewer.exe"; // home
           if (File.Exists(curFile))
           {
               Path = @"C:\Program Files\TeamViewer\Version7\TeamViewer.exe"; // 32bit
               //Path = @"C:\Program Files (x86)\TeamViewer\Version9\TeamViewer.exe"; // home
               Process p = System.Diagnostics.Process.Start(Path, PartnerIP);
               Thread.Sleep(500); // Allow the process to open it's window

           }
           else
           {

               curFile = @"C:\Program Files (x86)\TeamViewer\Version7\TeamViewer.exe";
               if (File.Exists(curFile))
               {
                   Path = @"C:\Program Files (x86)\TeamViewer\Version7\TeamViewer.exe"; // 64bit
                   Process p = System.Diagnostics.Process.Start(Path, PartnerIP);
                   Thread.Sleep(500); // Allow the process to open it's window

               }
               else
               {

               }
           }
       }
Posted 4 days ago
Updated 4 days ago
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

This doesn't make any sense.

ASP.NET code runs ENTIRELY on the server, never on the clients. This code is trying to kill TeamViewer ON THE SERVER.

So, if you're expecting this code to kill TeamViewer on the client machines, that's not going to work at all.

You also cannot kill a process on a client, even from javascript running in the HTML page your clients get.

You also cannot launch processes on client machines, nor get access to the clients filesystem.
  Permalink  
v3
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

The error message is pretty explicit: you do not have permission to close all TeamViewer processes on that computer.

So start with the debugger and find out exactly what process you are trying to kill. Then use the Task Manager to find who owns the process, and if it is one you should be trying to kill.

We can't do that for you - we have no access at all to your machine!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180920.1 | Last Updated 16 Sep 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100