Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hiding process DOS boxes, How?

11 views
Skip to first unread message

jcrouse

unread,
Jul 13, 2004, 4:28:25 PM7/13/04
to
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


Herfried K. Wagner [MVP]

unread,
Jul 13, 2004, 4:34:17 PM7/13/04
to
* "jcrouse" <me> scripsit:

> 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()
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

jcrouse

unread,
Jul 13, 2004, 6:13:10 PM7/13/04
to
There is no "p.WaitForExit()" or am I missing something here?

Thanks,
John

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:OQ3TMjRa...@TK2MSFTNGP10.phx.gbl...

Herfried K. Wagner [MVP]

unread,
Jul 13, 2004, 7:00:56 PM7/13/04
to
* "jcrouse" <me> scripsit:

> 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()

jcrouse

unread,
Jul 13, 2004, 8:14:43 PM7/13/04
to
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

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message

news:%23NXiF1S...@TK2MSFTNGP10.phx.gbl...

Herfried K. Wagner [MVP]

unread,
Jul 13, 2004, 8:38:07 PM7/13/04
to
* "jcrouse" <me> scripsit:

> 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

'>' is a feature of the command shell. You will have to start "cmd.exe"
and then launch your app from the command line. A sample for grabbing
the command line's output can be found here:

<URL:http://dotnet.mvps.org/dotnet/samples/miscsamples/downloads/RedirectConsole.zip>

Greg Burns

unread,
Jul 13, 2004, 9:20:17 PM7/13/04
to
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" <me> wrote in message
news:ON2bLeTa...@TK2MSFTNGP10.phx.gbl...

0 new messages