473,811 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ 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.

ProcessStartInf o info = new ProcessStartInf o("cmd.exe");
info.UseShellEx ecute = false;
info.RedirectSt andardInput = true;
info.RedirectSt andardError = true;
info.RedirectSt andardOutput = true;
using (Process install = Process.Start(i nfo))
{
string output = install.Standar dOutput.ReadToE nd();
install.WaitFor Exit();
Console.WriteLi ne(output);
}

I'm badly stuck. Please help.

Anand

Jan 12 '06 #1
3 3110
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**********@g mail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.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.

ProcessStartInf o info = new ProcessStartInf o("cmd.exe");
info.UseShellEx ecute = false;
info.RedirectSt andardInput = true;
info.RedirectSt andardError = true;
info.RedirectSt andardOutput = true;
using (Process install = Process.Start(i nfo))
{
string output = install.Standar dOutput.ReadToE nd();
install.WaitFor Exit();
Console.WriteLi ne(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**********@g mail.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.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.

ProcessStartInf o info = new ProcessStartInf o("cmd.exe");
info.UseShellEx ecute = false;
info.RedirectSt andardInput = true;
info.RedirectSt andardError = true;
info.RedirectSt andardOutput = true;
using (Process install = Process.Start(i nfo))
{
string output = install.Standar dOutput.ReadToE nd();
install.WaitFor Exit();
Console.WriteLi ne(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
6962
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 Runtime on Windows 2000, so I can use it. I tried all below cases. String cmd = "C:\WINNT\system32\cmd.exe";
2
35772
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 Process.StandardInput.Close() before I can call Process.StandardOutput.ReadToEnd() - and I cannot use the StandardInput thereafter. Here is the code:
0
3950
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 a RichTextBox where I'm doing stuff to the text. I'm also passing the characters typed to the RichTextBox to StandardInput for cmd.exe. This is all working quite well, but the problem is that I cannot get cmd.exe to process Ctrl-C correctly. ...
2
2549
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 7.0\Reader\test.pdf" "labelprinter" the document test.pdf will be printed on labelprinter. Now, labelprinter is set for non-default draw "Casette nr 2" and the line
1
4084
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: Process cmd = new Process(); StreamWriter sw; StreamReader sr;
1
7473
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 # ---------------------------------------------------------------------- # Script "shortcut.py" import os
1
8316
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 PID of the cmd file. I don't want to use a method like GetAllProcesses(). If I want to kill the processes (both the cmd and the exe) I have to kill the exe. Otherwise the exe process is still alive. The "taskkill" command is also not helpful...
1
3976
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 'permission denied' error at this line 48... 48 Call oScript.Run ("C:\inetpub\wwwroot\test\cmd.exe /c " & strCMD & " > " & strTempFile, 0, True) I am stumbling with permissions here. Here is where my cmd.exe lives (i copied it from system32)...
2
10536
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 IE7 browser running under administrator xp account login
0
9734
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
10652
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
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
10408
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
9211
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...
0
6895
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3026
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.