IT Community - Software Programming, Web Development and Technical Support

How to call a program using the command prompt from ASP.NET. Basically all it needs

This is a discussion on How to call a program using the command prompt from ASP.NET. Basically all it needs within the ASP and ASP.NET Programming forums, part of the Web Development category; How to call a program using the command prompt from ASP.NET. Basically all it needs to do is (upon ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-26-2007, 12:05 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Question How to call a program using the command prompt from ASP.NET. Basically all it needs

How to call a program using the command prompt from ASP.NET. Basically all it needs to do is (upon pressing a button)call the prompt, 'cd' to the right directory and execute the appropriate app. Is there an easy way to do this?
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-26-2007, 12:05 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 633
oxygen is on a distinguished road
Default Re: How to call a program using the command prompt from ASP.NET. Basically all it nee

// Get a file name relative to the current Web app.
string file = Server.MapPath(@"binMyApp.exe");

ProcessStartInfo info = new ProcessStartInfo(file, "args");
// Redirect output so we can read it.
info.RedirectStandardOutput = true;
// To redirect, we must not use shell execute.
info.UseShellExecute = false;

// Create and execute the process.
Process p = Process.Start(info);
p.Start();

// Send whatever was returned through the output to the client.

Response.Write(p.StandardOutput.ReadToEnd());
Note that the ASP.NET worker process needs to have permissions to access the external application. The most simple way to ensure this is to place it under the bin folder.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
difference between call by value and call by reference amansundar Java Programming 2 09-18-2007 01:34 AM
Get dos prompt simplesabita Testing Tools 1 08-22-2007 04:39 AM
Function call and System call vigneshgets Operating Systems 1 08-01-2007 06:18 AM
How to launch Real Player program through my j2me midlet program? itbarota J2ME 1 07-25-2007 11:39 PM
How can I invoke another program or command and trap its output in C? Sabari C and C++ Programming 1 07-17-2007 04:01 AM


All times are GMT -7. The time now is 01:16 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0