Solved

VB.net Hide a DOS Window on Process Start

Posted on 2014-10-03
4
315 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 62

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now