Solved

VB.net Hide a DOS Window on Process Start

Posted on 2014-10-03
4
341 Views
Last Modified: 2014-10-06
Hello Experts!
OK, I CAN NOT figure this out...so HELP!

Why does my DOS Window Show?  I don't want the Process DOS Window to Show!

                    myProcess = New Process
                    With myProcess
                        .StartInfo.RedirectStandardError = True
                        .StartInfo.RedirectStandardOutput = True
                        .StartInfo.UseShellExecute = False
                        .StartInfo.CreateNoWindow = True
                        .StartInfo.FileName = ConfigurationManager.AppSettings("ExportProgram")
                        .StartInfo.Arguments = " action=OutUpdate xml=" & sFile.FullName & " outputFile=" & sLogFile
                        .StartInfo.WorkingDirectory = ConfigurationManager.AppSettings("WorkingDirectory")
                    End With

                    myProcess.Start()
                    Application.DoEvents()
0
Comment
Question by:smithmrk
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40360204
Try using the show window function to hide it:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function FindWindow( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As IntPtr
End Function

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As ShowWindowCommands) As Boolean
End Function



Dim hWnd as IntPtr  = FindWindow(null, "name of the window")
if (hWnd <> IntPtr.Zero) then 
     ShowWindow(hWnd, 0)  'SW_HIDE
end if

Open in new window

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40360216
The CreateNoWindow  has the meaning, "Gets or sets a value indicating whether to start the process in a new window.", not what you are looking for.

Replace this line in the code.

.StartInfo.CreateNoWindow = True

With this line of code.

.StartInfo.WindowStyle = ProcessWindowStyle.Hidden

See if this give you what you are looking for.
0
 

Author Comment

by:smithmrk
ID: 40363497
This has a blue line under it?
It doesn't like this:

<DllImport

Mark
0
 

Author Closing Comment

by:smithmrk
ID: 40363890
I figured out my problem!

Thanks,
Mark
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …

749 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