473,493 Members | 4,147 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Run 'cmd.exe' from aspx page

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

Jan 12 '06 #1
3 3056
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
<an**********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
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

Jan 12 '06 #2
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.
<an**********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
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

Jan 12 '06 #3
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

Jan 13 '06 #4

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

Similar topics

1
6921
by: maya2000 | last post by:
Hello, I searched this java newsgroup and tried all suggestions, but still failed. I keep watch a task manager, but cmd.exe never running. All I want to do is run and pop up the cmd.exe using...
2
35718
by: Andreas Schmid | last post by:
Hi, I tried to launch Cmd.exe using System.Diagnostics and interact with it - issue commands and read their output. However, I only seem to be able to issue one command since I have to call...
0
3899
by: B Loggins | last post by:
Hi everyone, thanks in advance fo any help on this issue. I'm trying to "wrap" cmd.exe. That is, I'm redirecting StandardInput and StandardOutput for a cmd.exe process and I'm sending StdOut to...
2
2527
by: joe1977 | last post by:
Win2k3, PHP 5, Apache 2, Acrobat 7 when I go to my server, pull out cmd.exe and type as follows: "c:\Program Files\Adobe\Acrobat 7.0\\Reader\AcroRd32.exe" /t "c:\Program Files\Adobe\Acrobat...
1
4067
by: Robert | last post by:
Hello, I am doing an automatic backup service using c# and VS2003. To achieve this i must call an executable file. So far I have made it all work using Process, code looks like this: ...
1
7402
by: Nico Grubert | last post by:
Dear Python developers, I use a short python script in order to run an external application plus to open a browser displaying a default page. My Setup: Python 2.4.3. / Windows2000 #...
1
8303
by: Christoph | last post by:
I have a cmd file (batch file) which starts an exe after setting parameters. I need to find out the Process ID of the exe via a command. The problem is that my program, written in C# only knows the...
1
3957
by: jweiss | last post by:
I am trying to run cmd.exe so that I can ftp a file to a remote server. I've been doing this for a long time, but something broke. I did some windows updates last week?? I am getting a...
2
10513
by: =?Utf-8?B?c3RldmV3YQ==?= | last post by:
Microsoft VBScript runtime error '800a0046' Permission denied ======================= Trying to find the solution is driving me crazy. Using IIS6 on Server2003 SBS Default website localhost...
0
7119
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,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7195
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...
1
6873
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...
0
7367
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
5453
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
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.