473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

using System.Diagnostics.Process

Hi!

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

private void Page_Load(object sender, System.EventArgs e)
{

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

meProc.StartInfo.UseShellExecute = false;
meProc.StartInfo.CreateNoWindow = true;
meProc.StartInfo.RedirectStandardError = true;
meProc.StartInfo.RedirectStandardOutput = true;

meProc.Start();
string output = meProc.StandardError.ReadToEnd();
meProc.WaitForExit();

Response.Write (output);
}

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

Help is appreciated.

Morten


Nov 16 '05 #1
1 6012
This is the normal behavior, when using System.Diagnostics.Process.Start,
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***************@TK2MSFTNGP11.phx.gbl...
Hi!

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

private void Page_Load(object sender, System.EventArgs e)
{

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

meProc.StartInfo.UseShellExecute = false;
meProc.StartInfo.CreateNoWindow = true;
meProc.StartInfo.RedirectStandardError = true;
meProc.StartInfo.RedirectStandardOutput = true;

meProc.Start();
string output = meProc.StandardError.ReadToEnd();
meProc.WaitForExit();

Response.Write (output);
}

I've specified that impersonation should be used in web.config (<identity
impersonate="true"/>) and I've specified that the anonymous user should be
"Administrator" 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
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...
4
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...
0
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? ...
3
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...
1
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....
3
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...
0
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....
5
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...
4
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: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...
0
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...

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.