Click here to Skip to main content
15,896,912 members

Access denied while open process in ASP ?

sam9787 asked:

Open original thread
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
               {

               }
           }
       }
Tags: C#, ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900