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:
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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.
Set WshShell = CreateObject("WScript.Shell")
You will receive the usual warning about security and ActiveX execution.
Dig Deeper on Win Development Resources
Related Q&A from Daniel Cazzulino
Here Daniel Cazzulino explains how to load a DSL (domain specific language) domain model instance file programmatically. This requires the .NET type ... Continue Reading
Here we offer a glimpse at 12 of .NET development expert Danny Cazzulino's top ASP.NET questions and answers. Continue Reading
C# developers should NOT be modifying InitializeComponent method in the code-behind (or any of the variable definitions) by hand. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.