Well Herfried, I'm stuck. Here is my code:
Dim strInput1 As String = (lblMameExePath .Text & " -listinfo >C:\test.cfg" )
Dim p As New System.Diagnost ics.ProcessStar tInfo
p.Verb = "print"
p.CreateNoWindo w = True
p.WindowStyle = ProcessWindowSt yle.Hidden
p.UseShellExecu te = False
p.Arguments = " -listinfo> C:\test.cfg"
p.FileName = "C:\mame\mame.e xe"
Dim pr As System.Diagnost ics.Process = System.Diagnost ics.Process.Sta rt(p)
System.Diagnost ics.Process.Sta rt(p)
pr.WaitForExit( )
response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.Inf ormation, "CPViewer")
I am trying to keep it simple to get it working. The actual commandline is
"C:\Mame\Mame.e xe -listinfo> C:\Program Files\CPViewer\ MameGames.cfg". In my
code I want to use Application.Sta rtupPath 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.Sta rtupPath & "\CreateMameGam esCFG.bat"
Dim sr As StreamWriter = File.CreateText (strInput)
sr.WriteLine(lb lMameExePath.Te xt & " -listinfo >""" &
Application.Sta rtupPath & "\mamegames.cfg """)
sr.Close()
Dim p As New System.Diagnost ics.ProcessStar tInfo
p.WindowStyle = ProcessWindowSt yle.Hidden
p.FileName = strInput
p.UseShellExecu te = True
System.Diagnost ics.Process.Sta rt(p)
response = MsgBox("Your file has been created successfully.",
MsgBoxStyle.Inf ormation, "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(App lication.Startu pPath & "\CreateMameGam esCFG.bat") Then
Dim path3 As String = Application.Sta rtupPath & "\CreateMameGam esCFG.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******** ********@TK2MSF TNGP10.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.Diagnost ics.ProcessStar tInfo()
p.Verb = "print"
p.CreateNoWindo w = True
p.WindowStyle = ProcessWindowSt yle.Hidden
p.FileName = "C:\filename.ex e"
Dim pr As System.Diagnost ics.Process = System.Diagnost ics.Process.Sta rt(p)
pr.WaitForExit( )
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>