By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,240 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,240 IT Pros & Developers. It's quick & easy.

Hiding process DOS boxes, How?

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
* "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/>
Nov 20 '05 #2

P: n/a
There is no "p.WaitForExit()" or am I missing something here?

Thanks,
John

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OQ**************@TK2MSFTNGP10.phx.gbl...
* "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/>

Nov 20 '05 #3

P: n/a
* "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()
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

P: n/a
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]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
* "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()
///

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

Nov 20 '05 #5

P: n/a
* "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>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

P: n/a
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:ON**************@TK2MSFTNGP10.phx.gbl...
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]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
* "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()
///

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


Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.