473,663 Members | 2,876 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using System.Diagnost ics.Process

Hi!

Does anyone know why the code below always returns an "access is denied"
error?

private void Page_Load(objec t sender, System.EventArg s e)
{

System.Diagnost ics.Process meProc = System.Diagnost ics.Process.Sta rt
("cmd.exe", " /c echo y| CACLS C:\\Temp /E /T /G test:F");

meProc.StartInf o.UseShellExecu te = false;
meProc.StartInf o.CreateNoWindo w = true;
meProc.StartInf o.RedirectStand ardError = true;
meProc.StartInf o.RedirectStand ardOutput = true;

meProc.Start();
string output = meProc.Standard Error.ReadToEnd ();
meProc.WaitForE xit();

Response.Write (output);
}

I've specified that impersonation should be used in web.config (<identity
impersonate="tr ue"/>) and I've specified that the anonymous user should be
"Administra tor" on the virtual directory that I'm using for my web
application.

Help is appreciated.

Morten


Nov 16 '05 #1
1 6054
This is the normal behavior, when using System.Diagnost ics.Process.Sta rt,
the new process uses the token for the calling process, not the
impersonation token of the calling thread.
To spawn other processes you need to run the asp.net worker process as
administrator, something I would never suggest. Much better is to run this
code from a COM+ out-proc application that runs with a fixed administrators
identity.

Willy.
"Morten" <mo************ **@hotmail.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
Hi!

Does anyone know why the code below always returns an "access is denied"
error?

private void Page_Load(objec t sender, System.EventArg s e)
{

System.Diagnost ics.Process meProc = System.Diagnost ics.Process.Sta rt
("cmd.exe", " /c echo y| CACLS C:\\Temp /E /T /G test:F");

meProc.StartInf o.UseShellExecu te = false;
meProc.StartInf o.CreateNoWindo w = true;
meProc.StartInf o.RedirectStand ardError = true;
meProc.StartInf o.RedirectStand ardOutput = true;

meProc.Start();
string output = meProc.Standard Error.ReadToEnd ();
meProc.WaitForE xit();

Response.Write (output);
}

I've specified that impersonation should be used in web.config (<identity
impersonate="tr ue"/>) and I've specified that the anonymous user should be
"Administra tor" on the virtual directory that I'm using for my web
application.

Help is appreciated.

Morten

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
8364
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with a handler. The handler portion seems to fail indicating that my parameters are invalid. I am getting an error code 126 when i try to register the handler and 28 when i register for event notification. Any ideas as to what the deal is? I am...
4
5666
by: Ohad Young | last post by:
Hi, I need to open (launch) an external application from my winform application. The application is not a dot.net application, for example the windows calculator. I'm using the System.Diagnostics.Process class, for example: .... System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.EnableRaisingEvents = false;
0
3293
by: Daniel Reber | last post by:
I am trying to start a process from a windows service but when the process starts the command window that the process runs in never shows. Is this because I am calling it from a windows service? Is there something else that I need to do? Here is my code: System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo();
3
6899
by: vbMark | last post by:
Here is my C# code in the ASP.NET page. public static void DoConvert ( string sFile ) { string cmd = "foo.exe" ; string param = " /bar.txt" ; Process myproc ; // <-- Error here ProcessStartInfo startInfo = new ProcessStartInfo ( cmd , param ) ; startInfo.CreateNoWindow = true ; startInfo.WindowStyle = ProcessWindowStyle.Hidden ;
1
3043
by: Heiko Besemann | last post by:
Dear group, I created an aspx page using System.Diagnostics.Process() to launch "tracert" from shell and redirect output to Response.Output which prints it as text/plain into my browsers window. Now that works fine so far. My problem is that while tracert process is running and ASP ..NET is putting data into the pages output stream, my webapplication is locked until tracert process exits. How can I stop locking my application and be...
3
13375
by: K.NagaKiranKumar | last post by:
Hi I have stucked up on a problem.... I am developing an application in VB.NET Here I have to put a button on a form and by clicking on that button, an exe should run. see the code I am using... ------------------
0
1798
by: Daniel | last post by:
System.Diagnostics.Process.Start fails on windows server 2003 the process returns process.ExitCode == 0 but executing any process with System.Diagnostics.Process.Start on windows xp works fine. anything to do different for windows server 2003? some special permission for the process that executes another executable with System.Diagnostics.Process.Start ?? here is the code:
5
8348
by: rohitkumar | last post by:
I am trying to build a web application which can execute dos print command on the client machine. This application will read a file stored in server and it will create a folder on client machine and store the file there for future reference.it will also print the contents on the printer attached on client machine. I M using dos command because other options requires manual file>print options to print the file and number of files is too...
4
8450
by: =?Utf-8?B?YmlsbA==?= | last post by:
i'm using VS2005, VB.NET windows forms application when I try to open a web page using process.start, i get an error: "application not found" I'm using this syntax: System.Diagnostics.Process.Start("http://www.microsoft.com/") It works if I do it like this (thank you HKW), but what if the user doesn't use IE, but uses some other browser?
0
8436
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8771
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
8548
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
8634
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
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
6186
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...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1757
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.