Problem solve Get help with specific problems with your technologies, process and projects.

In ASP.NET, how can I open an MS-DOS window using a hyperlink?

I am working on ASP.NET and I would like to know how I can open an MS-DOS window by using a hyperlink. Can you tell/show me how to do this?
There are two sides to this question. You may want to execute a program from the command prompt on the server side, after a click in a hyperlink server control, or you may want to open the commmand prompt on the client side after the user clicks a link.

The first case may be achieved with the following code in the hyperlink's click event handler:


You can also use the ProcessStartInfo class in the same namespace to gain better control over the process execution, such as redirecting the standard input/output streams, waiting for completion, etc.

The second case is a matter of client-side scripting. I'm sure there are other ways of doing this, but one of them is using the Shell object from WSH (which must be installed on the client machine, of course):

Set WshShell = CreateObject("WScript.Shell")

You will receive the usual warning about security and ActiveX execution.

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.