Solved

VB.net Hide a DOS Window on Process Start

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Populating an array of locale_time_info 8 46
VB.Net Report Printing Issue 3 35
location of a form 2 15
Create a datatable in vb.net dynamically 1 16
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

823 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