Click here to Skip to main content
15,902,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am relativly new to vb.net ..... heck I'm new to
VB in any version. So I
apologize if this is overly dumb.
I am trying to start and stop a particular file
using the process.start()
and process.kill().
These are working but the DOS window is always
appearing.
What am I missing to hide the DOS window?
I have tried .hidden, .minimized, removed the
window style completeley. I
haven't found a way to hide the DOS window.
Any help is appreciated.


VB
Dim mProcess As Process 'form level
Private Sub Form1_Load(ByVal sender As Object,
    ByVal e As System.EventArgs)
    Handles MyBase.Load
    mProcess = New Process
    With mProcess.StartInfo
        ..FileName = "repstore.exe"
        ..Arguments = "3104"
        ..UseShellExecute = False
        ..WindowStyle = ProcessWindowStyle.Hidden
        ..RedirectStandardOutput = True
        ..RedirectStandardInput = True
        End With
    End Sub
Private Sub btnStart_Click(ByVal sender As
    System.Object, ByVal e As
    System.EventArgs) Handles btnStart.Click
    mProcess.Start()
    End Sub
Private Sub btnStop_Click(ByVal sender As
    Object, ByVal e As
    System.EventArgs) Handles btnStop.Click
    mProcess.Kill()
    End Sub


I am relativly new to vb.net ..... heck I'm new to
VB in any version. So I
apologize if this is overly dumb.
I am trying to start and stop a particular file
using the process.start()
and process.kill().
These are working but the DOS window is always
appearing.
What am I missing to hide the DOS window?
I have tried .hidden, .minimized, removed the
window style completeley. I
haven't found a way to hide the DOS window.
Any help is appreciated.


VB
Dim mProcess As Process 'form level
Private Sub Form1_Load(ByVal sender As Object,
    ByVal e As System.EventArgs)
    Handles MyBase.Load
    mProcess = New Process
    With mProcess.StartInfo
        ..FileName = "repstore.exe"
        ..Arguments = "3104"
        ..UseShellExecute = False
        ..WindowStyle = ProcessWindowStyle.Hidden
        ..RedirectStandardOutput = True
        ..RedirectStandardInput = True
        End With
End Sub
Private Sub btnStart_Click(ByVal sender As
    System.Object, ByVal e As
    System.EventArgs) Handles btnStart.Click
    mProcess.Start()
End Sub
Private Sub btnStop_Click(ByVal sender As
Object, ByVal e As
    System.EventArgs) Handles btnStop.Click
    mProcess.Kill()
End Sub


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 21-Dec-13 23:13pm
v2

1 solution

You need to set the Process.StartInfo.CreateNoWindow property to True as well.
That should fix it.

[edit]Wrong code style :doh: - OriginalGriff[/edit]
 
Share this answer
 
v2
Comments
expert-programmer 23-Dec-13 1:07am    
not working boss ... sorry
OriginalGriff 23-Dec-13 4:50am    
For an "expert-programmer", you should know that "not working" is pretty unhelpful! :laugh:
Show exactly the code you tried (So we can be sure it's all in the right place) and describe what does happen.

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