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

Is pausing of the process needed here?

P: n/a
Here is my code:

Dim sw As StreamWriter = File.CreateText(Application.StartupPath
& "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the
batch file to create the text file. I then look inside the text file to get
a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet to
be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John

Nov 20 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
More......This code is executed on a button click event. If after executing
it, I execute it a second time, the label control populates properly.

Thanks,
John

"jcrouse" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the
batch file to create the text file. I then look inside the text file to get a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet to be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John


Nov 20 '05 #2

P: n/a
>If so, how do I put a momentary pause in the code?

Thread.Sleep(1000)

Greg
Nov 20 '05 #3

P: n/a
Why not skip creating and launching the batch file and just launch MAME
directly?

Dim p As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help >""" & Application.StartupPath & "\mameversion.txt""")

p.WindowStyle = ProcessWindowStyle.Hidden
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)

PS: mine was 0.81, what version are they upto nowadays? :)

Greg
Nov 20 '05 #4

P: n/a
Mine is .81 also, .84 was just released.
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
Why not skip creating and launching the batch file and just launch MAME
directly?

Dim p As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help >""" & Application.StartupPath & "\mameversion.txt""")

p.WindowStyle = ProcessWindowStyle.Hidden
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)

PS: mine was 0.81, what version are they upto nowadays? :)

Greg

Nov 20 '05 #5

P: n/a
It seems to think thread needs declared?

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eX**************@TK2MSFTNGP12.phx.gbl...
If so, how do I put a momentary pause in the code?


Thread.Sleep(1000)

Greg

Nov 20 '05 #6

P: n/a
Got it. I forgot the Imports System.Threading

Thanks,
John

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eI**************@TK2MSFTNGP10.phx.gbl...
Why not skip creating and launching the batch file and just launch MAME
directly?

Dim p As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help >""" & Application.StartupPath & "\mameversion.txt""")

p.WindowStyle = ProcessWindowStyle.Hidden
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)

PS: mine was 0.81, what version are they upto nowadays? :)

Greg

Nov 20 '05 #7

P: n/a
Still no-worky. What the heck am I missing here?

Thanks,
John

"jcrouse" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the
batch file to create the text file. I then look inside the text file to get a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet to be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John


Nov 20 '05 #8

P: n/a
John, check this out:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

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

psi.UseShellExecute = False
psi.RedirectStandardOutput = True

Dim myProcess As New Process
myProcess = Process.Start(psi)
Dim strLine As String = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit()

txtMameVersion.Text = Mid(strLine, 11, 4)

End Sub

Greg

"jcrouse" <me> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
Still no-worky. What the heck am I missing here?

Thanks,
John

"jcrouse" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim sw As StreamWriter =

File.CreateText(Application.StartupPath
& "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing
the
batch file to create the text file. I then look inside the text file to

get
a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet

to
be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John



Nov 20 '05 #9

P: n/a
Well, here im my exact code, copy and pasted:

Dim psi As New
System.Diagnostics.ProcessStartInfo(lblMameExePath .Text & " -help")

psi.UseShellExecute = False

psi.RedirectStandardOutput = True

Dim myProcess As New Process

myProcess = Process.Start(psi)

Dim strline As String = myProcess.StandardOutput.ReadToEnd

myProcess.WaitForExit()

lblMameVersion.Text = Mid(strline, 11, 4)
When it gets to the line, myProcess = Process.Start(psi) it errors out
saying it can't find the file specified. When I throw a quickwatch on psi it
looks like this:

FileName "C:\Mame\mame.exe -help" String

This appears to be just what I want. Any idea why I get a file not specified
error?

Thanks,
John
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
John, check this out:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

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

psi.UseShellExecute = False
psi.RedirectStandardOutput = True

Dim myProcess As New Process
myProcess = Process.Start(psi)
Dim strLine As String = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit()

txtMameVersion.Text = Mid(strLine, 11, 4)

End Sub

Greg

"jcrouse" <me> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
Still no-worky. What the heck am I missing here?

Thanks,
John

"jcrouse" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim sw As StreamWriter =

File.CreateText(Application.StartupPath
& "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt") Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing
the
batch file to create the text file. I then look inside the text file to

get
a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in the debugger, it works fine. I think a run-time speed the version is yet
to
be found when I try to write it to the label control. Could I be

correct here? If so, how do I put a momentary pause in the code?

Thanks,
John




Nov 20 '05 #10

P: n/a
I think this line is incorrect:
Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text &
" -help")

Try it like this (the command argument need to be the second parameter):
Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help")

I don't have my demo here at work, to compare the rest.

Greg

"jcrouse" <me> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Well, here im my exact code, copy and pasted:

Dim psi As New
System.Diagnostics.ProcessStartInfo(lblMameExePath .Text & " -help")

psi.UseShellExecute = False

psi.RedirectStandardOutput = True

Dim myProcess As New Process

myProcess = Process.Start(psi)

Dim strline As String = myProcess.StandardOutput.ReadToEnd

myProcess.WaitForExit()

lblMameVersion.Text = Mid(strline, 11, 4)
When it gets to the line, myProcess = Process.Start(psi) it errors out
saying it can't find the file specified. When I throw a quickwatch on psi it looks like this:

FileName "C:\Mame\mame.exe -help" String

This appears to be just what I want. Any idea why I get a file not specified error?

Thanks,
John
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
John, check this out:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

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

psi.UseShellExecute = False
psi.RedirectStandardOutput = True

Dim myProcess As New Process
myProcess = Process.Start(psi)
Dim strLine As String = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit()

txtMameVersion.Text = Mid(strLine, 11, 4)

End Sub

Greg

"jcrouse" <me> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
Still no-worky. What the heck am I missing here?

Thanks,
John

"jcrouse" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
> Here is my code:
>
> Dim sw As StreamWriter =
File.CreateText(Application.StartupPath
> & "\mameversion.bat")
>
> sw.WriteLine(lblMameExePath.Text & " -help >""" &
> Application.StartupPath & "\mameversion.txt""")
>
> sw.Close()
>
> Dim p As New System.Diagnostics.ProcessStartInfo
>
> p.WindowStyle = ProcessWindowStyle.Hidden
>
> p.FileName = Application.StartupPath & "\mameversion.bat"
>
> p.UseShellExecute = True
>
> System.Diagnostics.Process.Start(p)
>
> If File.Exists(Application.StartupPath & "\mameversion.txt")> Then
>
> Dim sr As StreamReader = New
> StreamReader(Application.StartupPath & "\mameversion.txt")
>
> strLine = sr.ReadLine()
>
> sr.Close()
>
> lblMameVersion.Text = Mid(strLine, 11, 4)
>
> frm1.dblMameVer =
> System.Convert.ToDouble(lblMameVersion.Text)
>
> lblMameVersion.Refresh()
>
> End If
>
>
>
> What is happening is that I am creating the batch file, then executing> the
> batch file to create the text file. I then look inside the text file to get
> a version number of the program. If I execute the code fast the version> number never gets written into the label control. If I step through
it
in> the debugger, it works fine. I think a run-time speed the version is yet to
> be found when I try to write it to the label control. Could I be correct> here? If so, how do I put a momentary pause in the code?
>
> Thanks,
> John
>
>
>
>
>



Nov 20 '05 #11

P: n/a
That did it. I was passing it as a string as opposed to two seperate
parametrers. Now, is there a way to hide the DOS box that pops up?

Thanks alot,
John

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I think this line is incorrect:
Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text &
" -help")

Try it like this (the command argument need to be the second parameter):
Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help")

I don't have my demo here at work, to compare the rest.

Greg

"jcrouse" <me> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Well, here im my exact code, copy and pasted:

Dim psi As New
System.Diagnostics.ProcessStartInfo(lblMameExePath .Text & " -help")

psi.UseShellExecute = False

psi.RedirectStandardOutput = True

Dim myProcess As New Process

myProcess = Process.Start(psi)

Dim strline As String = myProcess.StandardOutput.ReadToEnd

myProcess.WaitForExit()

lblMameVersion.Text = Mid(strline, 11, 4)
When it gets to the line, myProcess = Process.Start(psi) it errors out
saying it can't find the file specified. When I throw a quickwatch on psi
it
looks like this:

FileName "C:\Mame\mame.exe -help" String

This appears to be just what I want. Any idea why I get a file not specified
error?

Thanks,
John
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
John, check this out:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

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

psi.UseShellExecute = False
psi.RedirectStandardOutput = True

Dim myProcess As New Process
myProcess = Process.Start(psi)
Dim strLine As String = myProcess.StandardOutput.ReadToEnd()
myProcess.WaitForExit()

txtMameVersion.Text = Mid(strLine, 11, 4)

End Sub

Greg

"jcrouse" <me> wrote in message
news:ut**************@TK2MSFTNGP11.phx.gbl...
> Still no-worky. What the heck am I missing here?
>
> Thanks,
> John
>
> "jcrouse" <me> wrote in message
> news:Od**************@tk2msftngp13.phx.gbl...
>> Here is my code:
>>
>> Dim sw As StreamWriter =
> File.CreateText(Application.StartupPath
>> & "\mameversion.bat")
>>
>> sw.WriteLine(lblMameExePath.Text & " -help >""" &
>> Application.StartupPath & "\mameversion.txt""")
>>
>> sw.Close()
>>
>> Dim p As New System.Diagnostics.ProcessStartInfo
>>
>> p.WindowStyle = ProcessWindowStyle.Hidden
>>
>> p.FileName = Application.StartupPath & "\mameversion.bat" >>
>> p.UseShellExecute = True
>>
>> System.Diagnostics.Process.Start(p)
>>
>> If File.Exists(Application.StartupPath &

"\mameversion.txt")
>> Then
>>
>> Dim sr As StreamReader = New
>> StreamReader(Application.StartupPath & "\mameversion.txt")
>>
>> strLine = sr.ReadLine()
>>
>> sr.Close()
>>
>> lblMameVersion.Text = Mid(strLine, 11, 4)
>>
>> frm1.dblMameVer =
>> System.Convert.ToDouble(lblMameVersion.Text)
>>
>> lblMameVersion.Refresh()
>>
>> End If
>>
>>
>>
>> What is happening is that I am creating the batch file, then

executing >> the
>> batch file to create the text file. I then look inside the text
file to > get
>> a version number of the program. If I execute the code fast the version >> number never gets written into the label control. If I step through

it
in
>> the debugger, it works fine. I think a run-time speed the version

is yet
> to
>> be found when I try to write it to the label control. Could I be

correct
>> here? If so, how do I put a momentary pause in the code?
>>
>> Thanks,
>> John
>>
>>
>>
>>
>>
>
>



Nov 20 '05 #12

P: n/a
psi.WindowStyle= ProcessWindowStyle.Hidden

untested

"jcrouse" <me> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
That did it. I was passing it as a string as opposed to two seperate
parametrers. Now, is there a way to hide the DOS box that pops up?

Thanks alot,
John

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
I think this line is incorrect:
Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text &
" -help")

Try it like this (the command argument need to be the second parameter):
Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help")

I don't have my demo here at work, to compare the rest.

Greg

"jcrouse" <me> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
Well, here im my exact code, copy and pasted:

Dim psi As New
System.Diagnostics.ProcessStartInfo(lblMameExePath .Text & " -help")

psi.UseShellExecute = False

psi.RedirectStandardOutput = True

Dim myProcess As New Process

myProcess = Process.Start(psi)

Dim strline As String = myProcess.StandardOutput.ReadToEnd
myProcess.WaitForExit()

lblMameVersion.Text = Mid(strline, 11, 4)
When it gets to the line, myProcess = Process.Start(psi) it errors out
saying it can't find the file specified. When I throw a quickwatch on psi
it
looks like this:

FileName "C:\Mame\mame.exe -help" String

This appears to be just what I want. Any idea why I get a file not

specified
error?

Thanks,
John
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
> John, check this out:
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click
>
> Dim psi As New
> System.Diagnostics.ProcessStartInfo(lblMameExePath .Text, " -help")
>
> psi.UseShellExecute = False
> psi.RedirectStandardOutput = True
>
> Dim myProcess As New Process
> myProcess = Process.Start(psi)
> Dim strLine As String = myProcess.StandardOutput.ReadToEnd()
> myProcess.WaitForExit()
>
> txtMameVersion.Text = Mid(strLine, 11, 4)
>
> End Sub
>
> Greg
>
> "jcrouse" <me> wrote in message
> news:ut**************@TK2MSFTNGP11.phx.gbl...
> > Still no-worky. What the heck am I missing here?
> >
> > Thanks,
> > John
> >
> > "jcrouse" <me> wrote in message
> > news:Od**************@tk2msftngp13.phx.gbl...
> >> Here is my code:
> >>
> >> Dim sw As StreamWriter =
> > File.CreateText(Application.StartupPath
> >> & "\mameversion.bat")
> >>
> >> sw.WriteLine(lblMameExePath.Text & " -help >""" &
> >> Application.StartupPath & "\mameversion.txt""")
> >>
> >> sw.Close()
> >>
> >> Dim p As New System.Diagnostics.ProcessStartInfo
> >>
> >> p.WindowStyle = ProcessWindowStyle.Hidden
> >>
> >> p.FileName = Application.StartupPath & "\mameversion.bat" > >>
> >> p.UseShellExecute = True
> >>
> >> System.Diagnostics.Process.Start(p)
> >>
> >> If File.Exists(Application.StartupPath &
"\mameversion.txt")
> >> Then
> >>
> >> Dim sr As StreamReader = New
> >> StreamReader(Application.StartupPath & "\mameversion.txt")
> >>
> >> strLine = sr.ReadLine()
> >>
> >> sr.Close()
> >>
> >> lblMameVersion.Text = Mid(strLine, 11, 4)
> >>
> >> frm1.dblMameVer =
> >> System.Convert.ToDouble(lblMameVersion.Text)
> >>
> >> lblMameVersion.Refresh()
> >>
> >> End If
> >>
> >>
> >>
> >> What is happening is that I am creating the batch file, then

executing
> >> the
> >> batch file to create the text file. I then look inside the text file
to
> > get
> >> a version number of the program. If I execute the code fast the

version
> >> number never gets written into the label control. If I step

through it
in
> >> the debugger, it works fine. I think a run-time speed the version

is yet
> > to
> >> be found when I try to write it to the label control. Could I be
correct
> >> here? If so, how do I put a momentary pause in the code?
> >>
> >> Thanks,
> >> John
> >>
> >>
> >>
> >>
> >>
> >
> >
>
>



Nov 20 '05 #13

P: n/a
On a somewhat similar note, here is another event I'm executing:

Dim strInput As String = Application.StartupPath & "\CreateMameGamesCFG.bat"
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")
Any idea how I can pause it until the process is complete before displaying
the msgbox. This process takes about 30 seconds or so. It is a 26MB text
file that's being created.

Thanks,
John


"jcrouse" <me> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
Well the problem seems to be this: the psi will take the windostyle
parameter but I need to apply it to myProcess and it won't accept it.

Any ideas,
John
"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
psi.WindowStyle= ProcessWindowStyle.Hidden

untested

"jcrouse" <me> wrote in message
news:Oq**************@tk2msftngp13.phx.gbl...
That did it. I was passing it as a string as opposed to two seperate
parametrers. Now, is there a way to hide the DOS box that pops up?

Thanks alot,
John

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
> I think this line is incorrect:
> Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text
&
> " -help")
>
> Try it like this (the command argument need to be the second parameter): > Dim psi As New System.Diagnostics.ProcessStartInfo(lblMameExePath .Text, > " -help")
>
> I don't have my demo here at work, to compare the rest.
>
> Greg
>
> "jcrouse" <me> wrote in message
> news:ex**************@tk2msftngp13.phx.gbl...
> > Well, here im my exact code, copy and pasted:
> >
> > Dim psi As New
> > System.Diagnostics.ProcessStartInfo(lblMameExePath .Text &
" -help") > >
> > psi.UseShellExecute = False
> >
> > psi.RedirectStandardOutput = True
> >
> > Dim myProcess As New Process
> >
> > myProcess = Process.Start(psi)
> >
> > Dim strline As String =
myProcess.StandardOutput.ReadToEnd
> >
> > myProcess.WaitForExit()
> >
> > lblMameVersion.Text = Mid(strline, 11, 4)
> >
> >
> > When it gets to the line, myProcess = Process.Start(psi) it errors
out > > saying it can't find the file specified. When I throw a quickwatch on psi
> it
> > looks like this:
> >
> > FileName "C:\Mame\mame.exe -help" String
> >
> > This appears to be just what I want. Any idea why I get a file not
> specified
> > error?
> >
> > Thanks,
> > John
> >
> >
> > "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message > > news:eY**************@TK2MSFTNGP10.phx.gbl...
> > > John, check this out:
> > >
> > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As
> > > System.EventArgs) Handles Button1.Click
> > >
> > > Dim psi As New
> > > System.Diagnostics.ProcessStartInfo(lblMameExePath .Text,
" -help") > > >
> > > psi.UseShellExecute = False
> > > psi.RedirectStandardOutput = True
> > >
> > > Dim myProcess As New Process
> > > myProcess = Process.Start(psi)
> > > Dim strLine As String =

myProcess.StandardOutput.ReadToEnd() > > > myProcess.WaitForExit()
> > >
> > > txtMameVersion.Text = Mid(strLine, 11, 4)
> > >
> > > End Sub
> > >
> > > Greg
> > >
> > > "jcrouse" <me> wrote in message
> > > news:ut**************@TK2MSFTNGP11.phx.gbl...
> > > > Still no-worky. What the heck am I missing here?
> > > >
> > > > Thanks,
> > > > John
> > > >
> > > > "jcrouse" <me> wrote in message
> > > > news:Od**************@tk2msftngp13.phx.gbl...
> > > >> Here is my code:
> > > >>
> > > >> Dim sw As StreamWriter =
> > > > File.CreateText(Application.StartupPath
> > > >> & "\mameversion.bat")
> > > >>
> > > >> sw.WriteLine(lblMameExePath.Text & " -help >""" &
> > > >> Application.StartupPath & "\mameversion.txt""")
> > > >>
> > > >> sw.Close()
> > > >>
> > > >> Dim p As New System.Diagnostics.ProcessStartInfo
> > > >>
> > > >> p.WindowStyle = ProcessWindowStyle.Hidden
> > > >>
> > > >> p.FileName = Application.StartupPath &
"\mameversion.bat"
> > > >>
> > > >> p.UseShellExecute = True
> > > >>
> > > >> System.Diagnostics.Process.Start(p)
> > > >>
> > > >> If File.Exists(Application.StartupPath &
> > "\mameversion.txt")
> > > >> Then
> > > >>
> > > >> Dim sr As StreamReader = New
> > > >> StreamReader(Application.StartupPath & "\mameversion.txt")
> > > >>
> > > >> strLine = sr.ReadLine()
> > > >>
> > > >> sr.Close()
> > > >>
> > > >> lblMameVersion.Text = Mid(strLine, 11, 4)
> > > >>
> > > >> frm1.dblMameVer =
> > > >> System.Convert.ToDouble(lblMameVersion.Text)
> > > >>
> > > >> lblMameVersion.Refresh()
> > > >>
> > > >> End If
> > > >>
> > > >>
> > > >>
> > > >> What is happening is that I am creating the batch file, then
> executing
> > > >> the
> > > >> batch file to create the text file. I then look inside the text file
> to
> > > > get
> > > >> a version number of the program. If I execute the code fast the > version
> > > >> number never gets written into the label control. If I step

through
> it
> > in
> > > >> the debugger, it works fine. I think a run-time speed the version is
> > yet
> > > > to
> > > >> be found when I try to write it to the label control. Could I be > > correct
> > > >> here? If so, how do I put a momentary pause in the code?
> > > >>
> > > >> Thanks,
> > > >> John
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #14

P: n/a
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" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim sw As StreamWriter = File.CreateText(Application.StartupPath & "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the
batch file to create the text file. I then look inside the text file to get a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in
the debugger, it works fine. I think a run-time speed the version is yet to be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John


Nov 20 '05 #15

P: n/a
Well, the code has been resolved. I started another thread for hiding of the
DOS boxes.

"jcrouse" <me> wrote in message news:Ow*************@TK2MSFTNGP09.phx.gbl...
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" <me> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
Here is my code:

Dim sw As StreamWriter =

File.CreateText(Application.StartupPath
& "\mameversion.bat")

sw.WriteLine(lblMameExePath.Text & " -help >""" &
Application.StartupPath & "\mameversion.txt""")

sw.Close()

Dim p As New System.Diagnostics.ProcessStartInfo

p.WindowStyle = ProcessWindowStyle.Hidden

p.FileName = Application.StartupPath & "\mameversion.bat"

p.UseShellExecute = True

System.Diagnostics.Process.Start(p)

If File.Exists(Application.StartupPath & "\mameversion.txt")
Then

Dim sr As StreamReader = New
StreamReader(Application.StartupPath & "\mameversion.txt")

strLine = sr.ReadLine()

sr.Close()

lblMameVersion.Text = Mid(strLine, 11, 4)

frm1.dblMameVer =
System.Convert.ToDouble(lblMameVersion.Text)

lblMameVersion.Refresh()

End If

What is happening is that I am creating the batch file, then executing the batch file to create the text file. I then look inside the text file to

get
a version number of the program. If I execute the code fast the version
number never gets written into the label control. If I step through it in the debugger, it works fine. I think a run-time speed the version is yet

to
be found when I try to write it to the label control. Could I be correct
here? If so, how do I put a momentary pause in the code?

Thanks,
John



Nov 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.