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

Calling a Windows application

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;
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")

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.