Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Start another application as a process

Posted on 2011-02-23
8
Medium Priority
?
384 Views
Last Modified: 2012-06-21
I want to run another application (a legacy application) as a process from my .NET Windows Application, and I want to hide the window of legacy application, I don't want it show up, how to do that?  I can't even hide a notepad or calculator, Notepad or Calculator still pop up, what am I missing?

private void button1_Click(object sender, System.EventArgs e)
{
Process myProcess = new Process();
try
{
myProcess.StartInfo.WindowStyle= ProcessWindowStyle.Hidden;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.FileName =@"C:\\WINDOWS\\system32\\notepad.exe";
myProcess.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
      
0
Comment
Question by:ToneElec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 10

Expert Comment

by:eguilherme
ID: 34962205
have you tried setting


myProcess.StartInfo.CreateNoWindow = true;

to false


myProcess.StartInfo.CreateNoWindow = false;
0
 
LVL 10

Expert Comment

by:eguilherme
ID: 34962214
 you can also try to set the WindowStyle = ProcessWindowStyle.Hidden;
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 34962561
To use the Hidden style, first set UseShellExecute() to TRUE:
private void button1_Click(object sender, System.EventArgs e)
        {
            Process myProcess = new Process();
            try
            {
                myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                myProcess.StartInfo.UseShellExecute = true;
                myProcess.StartInfo.FileName = "notepad.exe";
                myProcess.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ToneElec
ID: 34963383
Thank you for your reply.  Setting UseShellExecute() to TRUE make it work.  
0
 

Author Comment

by:ToneElec
ID: 34971667
This is something I don't understand, yesterday I set UseShellExecute() to TRUE, just as Idle_Mind mentioned, it worked and it hide the process window, no matter notepad, calculator or my program.  However, today it only hide notepad, not calculator, or my program.  What's going on?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34971688
It's possible you have a bug in your program and it's not compiling...and you are running a version that is not current?

Otherwise show us your current code...
0
 

Author Comment

by:ToneElec
ID: 34972525
Idle_Mind:

I made my executable program (VC++ 6.0) dialog box disabled, so it will run as a process, doesn't pop up the window.  Your program can successfully hide Notepad, for some  reason, it doesn't hide Calculator.  Is there a difference between those two?   I am using Microsoft Visual Studio 2003.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34973027
Not sure why some windows don't like being hidden...sorry.

Can you give the "big picture" of your project?  Maybe there is another approach that would work.
0

Featured Post

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question