Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m using these five lines of code, for another process, but somehow it is still not hidden, or to say it is still visible in window. Do you know what line of code am i missing?

What I have tried:

Dim myprocess As Process = New Process()
myprocess.StartInfo.FileName = "SW.exe"
myprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
myprocess.StartInfo.UseShellExecute = True
myprocess.StartInfo.CreateNoWindow = True
myprocess.Start()
myprocess.WaitForExit()
Posted
Updated 31-Mar-20 3:02am
v3

There's nothing wrong with that code but it is possible that SW.exe is ignoring the startup state 'request' from the operating system. For example a GUI windows application written with a System.Windows.Forms.Form and a Load event handler with the following code will ignore ProcessWindowStyles from Process.Start(...). It will always show as Normal.

C#
protected override void Form_Load(Object sender EventArgs e) {
  WindowState = FormWindowState.Normal;
}


A simple way of testing if your SW.exe is going to behave as you would wish is to start it via a shortcut. Modify the shortcut properties and set Run to either Maximised or Minimised. If that has no effect then SW.exe is ignoring ProcessWindowStyles.

Alan.
 
Share this answer
 
ProcessWindowStyle.Hidden doesn't hide a process - you can't do that - it just doesn't display a window by not actually drawing it at all.

A process doesn't have to have a window so it can be "invisible" on screen, but it does have to have a thread and a process space in which to run it and those will always appear in the Process list of Task Manager.
 
Share this answer
 
Comments
Marc Kane 30-Mar-20 16:55pm    
Yes, i am aware of that, but with this code it is visible, and i dont want that, so im trying to figure out the reason why it is still displayed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900