Hiding process DOS boxes, How?

  • Thread starter Thread starter jcrouse
  • Start date Start date
J

jcrouse

This is kind of a continuation of another thread that was somewhat resolved:

Well, the dilemma seems to be this. I want to be able to hide the DOS box
AND pause the code until execution is complete. If I create a process, I can
"WaitforExit" but not hide the DOS box. If I create a
"System.Diagnostics.Process", I can hide the DOS box but can't pause until
the execution is complete. How can I have the best of both worls?

Thank you,
John
 
* "jcrouse said:
Well, the dilemma seems to be this. I want to be able to hide the DOS box
AND pause the code until execution is complete. If I create a process, I can
"WaitforExit" but not hide the DOS box. If I create a
"System.Diagnostics.Process", I can hide the DOS box but can't pause until
the execution is complete. How can I have the best of both worls?

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.CreateNoWindow = True
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.exe"
System.Diagnostics.Process.Start(p)
p.WaitForExit()
///
 
* "jcrouse said:
There is no "p.WaitForExit()" or am I missing something here?

My bad. I made a mistake:

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.CreateNoWindow = True
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.exe"
Dim pr As System.Diagnostics.Process = System.Diagnostics.Process.Start(p)
pr.WaitForExit()
///
 
Well Herfried, I'm stuck. Here is my code:

Dim strInput1 As String = (lblMameExePath.Text & " -listinfo >C:\test.cfg")

Dim p As New System.Diagnostics.ProcessStartInfo

p.Verb = "print"

p.CreateNoWindow = True

p.WindowStyle = ProcessWindowStyle.Hidden

p.UseShellExecute = False

p.Arguments = " -listinfo> C:\test.cfg"

p.FileName = "C:\mame\mame.exe"

Dim pr As System.Diagnostics.Process = System.Diagnostics.Process.Start(p)

System.Diagnostics.Process.Start(p)

pr.WaitForExit()

response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.Information, "CPViewer")


I am trying to keep it simple to get it working. The actual commandline is
"C:\Mame\Mame.exe -listinfo> C:\Program Files\CPViewer\MameGames.cfg". In my
code I want to use Application.StartupPath in place of "C:\Program
Files\CPViewer" but I'll get to that later. I have another post somewhere
and have read others about spaces in paths and the command window not
agreeing. The above code executes without errors but not file is created. I
am using the following code sucessfully but can't pause it.

Dim strInput As String = Application.StartupPath & "\CreateMameGamesCFG.bat"


Dim sr As StreamWriter = File.CreateText(strInput)

sr.WriteLine(lblMameExePath.Text & " -listinfo >""" &
Application.StartupPath & "\mamegames.cfg""")

sr.Close()





Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = strInput

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.Information, "CPViewer")



As you can see, I create a batch file containing my command then execute the
batch file. I then remove the batch file upon exiting the form with this
code:

If File.Exists(Application.StartupPath & "\CreateMameGamesCFG.bat") Then

Dim path3 As String = Application.StartupPath & "\CreateMameGamesCFG.bat"

Dim fi3 As FileInfo = New FileInfo(path3)

fi3.Delete()

End If


BUT, I can't get the code to pause until the cfg file is created. What am I
missing here?

Thank you for your help,
John
 
John, why not use the code we came up with from before? Just add Herfried's
"CreateNoWindow". Once you have the string variable (output) filled, it is
pretty straight forward to just write that to a new text file named
"MameGames.cfg".

Greg

Me.Cursor = Cursors.WaitCursor

Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath.Text,
" -listinfo")

psi.UseShellExecute = False
psi.ErrorDialog = False
psi.RedirectStandardOutput = True
psi.RedirectStandardError = False
psi.CreateNoWindow = True

Dim myProcess As New Process
myProcess = Process.Start(psi)

Dim output As String = myProcess.StandardOutput.ReadToEnd()

myProcess.WaitForExit()

Dim path As String = "C:\Program Files\CPViewer\MameGames.cfg"

If File.Exists(path) Then
File.Delete(path)
End If

Dim sw As StreamWriter = New StreamWriter(path)
sw.WriteLine(output)
sw.Close()

Me.Cursor = Cursors.Default



jcrouse said:
Well Herfried, I'm stuck. Here is my code:

Dim strInput1 As String = (lblMameExePath.Text & " -listinfo
C:\test.cfg")

Dim p As New System.Diagnostics.ProcessStartInfo

p.Verb = "print"

p.CreateNoWindow = True

p.WindowStyle = ProcessWindowStyle.Hidden

p.UseShellExecute = False

p.Arguments = " -listinfo> C:\test.cfg"

p.FileName = "C:\mame\mame.exe"

Dim pr As System.Diagnostics.Process = System.Diagnostics.Process.Start(p)

System.Diagnostics.Process.Start(p)

pr.WaitForExit()

response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.Information, "CPViewer")


I am trying to keep it simple to get it working. The actual commandline is
"C:\Mame\Mame.exe -listinfo> C:\Program Files\CPViewer\MameGames.cfg". In
my
code I want to use Application.StartupPath in place of "C:\Program
Files\CPViewer" but I'll get to that later. I have another post somewhere
and have read others about spaces in paths and the command window not
agreeing. The above code executes without errors but not file is created.
I
am using the following code sucessfully but can't pause it.

Dim strInput As String = Application.StartupPath &
"\CreateMameGamesCFG.bat"


Dim sr As StreamWriter = File.CreateText(strInput)

sr.WriteLine(lblMameExePath.Text & " -listinfo >""" &
Application.StartupPath & "\mamegames.cfg""")

sr.Close()





Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = strInput

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.Information, "CPViewer")



As you can see, I create a batch file containing my command then execute
the
batch file. I then remove the batch file upon exiting the form with this
code:

If File.Exists(Application.StartupPath & "\CreateMameGamesCFG.bat") Then

Dim path3 As String = Application.StartupPath &
"\CreateMameGamesCFG.bat"

Dim fi3 As FileInfo = New FileInfo(path3)

fi3.Delete()

End If


BUT, I can't get the code to pause until the cfg file is created. What am
I
missing here?

Thank you for your help,
John
 
Back
Top