Run 'cmd.exe' from aspx page

A

anandjoshi77

Hi All,
I have a Asp.Net web application (code behind C#).
On one page I need to run "cmd.exe" from that page.
I can see that the "cmd.exe" is present in the task manager, but the
console window is not opening.
As I can not process further unless that window is opened, I'm stuck.
I'm trying to run this on Windows XP machine.


For a try I'm using this simple form with one button on it.
On click of button, I'm executing following code.

ProcessStartInfo info = new ProcessStartInfo("cmd.exe");
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardError = true;
info.RedirectStandardOutput = true;
using (Process install = Process.Start(info))
{
string output = install.StandardOutput.ReadToEnd();
install.WaitForExit();
Console.WriteLine(output);
}

I'm badly stuck. Please help.

Anand
 
R

Rick Strahl [MVP]

Anand,

You can't open a console window because ASP.NET runs as a service typically
under a service account and there's not desktop on that console.

How would you do anything with this Console anyway?

You can use the console applications and pipe in and out text via Stdin and
StdOut if and then display that via a Web page or some other HTTP response.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
 
G

George Ter-Saakov

The ASP.NER runs under different account than account you are logged in.
In Windows different accounts have different desktops.

So console window is opened but you simply do not see it. Monitor shows your
desktop that was being assigned to your account.

You can read more on that in MSDN. Look up Windows APIs
CreateDesktop, Window Station and Desktop Functions

George.
 
A

anandjoshi77

Hi Rick Strahl & George,
Thanks for your quick reply.
Let me clear one thing. There is one COM component, which is trying to
open this console window.
I do not have any control over the component I'm using.

When I use the same code with Windows Server 2003, (after making the
IIS_wpg group member of 'Administrator' & 'aspnet' member of
'Administrator'), it works fine.
It opens the console window and does the operations.

The problem is with only Windows XP or Windows Server 2000.

Is this because of the version of IIS? As Windows 2003 comes with IIS
6, where as XP / 2000 uses IIS 5?
Anand
 
Joined
May 17, 2006
Messages
1
Reaction score
0
Run exe

Hi Anand
Can u pls tell me how did u get through this problem.
How to use the COM compoent and the code to run the exe file.

Thanks in Advance


Hi Rick Strahl & George,
Thanks for your quick reply.
Let me clear one thing. There is one COM component, which is trying to
open this console window.
I do not have any control over the component I'm using.

When I use the same code with Windows Server 2003, (after making the
IIS_wpg group member of 'Administrator' & 'aspnet' member of
'Administrator'), it works fine.
It opens the console window and does the operations.

The problem is with only Windows XP or Windows Server 2000.

Is this because of the version of IIS? As Windows 2003 comes with IIS
6, where as XP / 2000 uses IIS 5?
Anand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top