Q

Calling a Windows application

This Content Component encountered an error

I developed a Web application. One of its functions is to call a Windows application. I use notepad.exe for testing purpose. However, the .exe does not show up on the screen. It is only running in the background when I check the Task Manager. My code looks like this:

Process DYProcess = new Process();
DYProcess.StartInfo.FileName = @"c:\winnt\notepad.exe";
DYProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
DYProcess.Start();
ASP.NET is a server application, and everything you code in C#, or any other .NET language, is executed on the server-side. Therefore, opening a Notepad application is just weird, to say the least. Do you expect some administrator to be sitting in front of the server waiting for a Windows application to open up in response to a user's request for a page? Being a server application, the ASP.NET worker process account doesn't even have the permission to open UI elements, because they can cause the process to be kept waiting for user response that may never come. After all, servers shouldn't even be used by end-users regularly; therefore, it's most probable that there is no user session initiated at all.

I bet what you're trying to do is start a Windows application on the client side. If that is the case, ASP.NET has nothing to do about it -- neither does .NET. You have to use plain JavaScript at the HTML level to start the process at some page event. 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, but comes built-in with WinXP/2k AFAIK):

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run("cmd.exe")

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

This was first published in October 2003

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.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close