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
\\\
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/>
Thanks,
John
"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:OQ3TMjRa...@TK2MSFTNGP10.phx.gbl...
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()
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...
'>' 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
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...