473,420 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,420 software developers and data experts.

Is pausing of the process needed here?

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
15 1410
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
>If so, how do I put a momentary pause in the code?

Thread.Sleep(1000)

Greg
Nov 20 '05 #3
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Srinath Avadhanula | last post by:
Hello, I am wondering if QT has something like QWaitForNextEvent() function. This function would block execution of the application till another key was pressed and then return the event...
3
by: Graham | last post by:
How can I cause a python program to pause/suspend execution for a period of time? I am checking status of an external system and only want to check every second as opposed to my current which...
12
by: Simon John | last post by:
I'm writing a PyQt network client for XMMS, using the InetCtrl plugin, that on connection receives a track length. To save on bandwidth, I don't want to be continually querying the server for...
1
by: jcrouse | last post by:
This is sort of a revisited item from about two months ago (don't get mad Cor) with additional code. I am creating a batch file called CreateMameGames.bat. I am then running that batch file to...
7
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
0
by: Grayzag | last post by:
Hi there, As part of my Software course, i have to create a game. Since I originally started out with python, I was used to it being really easy to create a main loop to control the game with a...
12
by: greg | last post by:
Hi, Can anyone help me with the following issue: How can I pause the execution of a program until a given file is created (by another process) in a specified directory? Any ideas would be...
3
by: Lucress Carol | last post by:
Hi everyone, I'm having troubles with pausing and continuing MFC Thread.For test purposes I've created in my MFC Dialog application a progress Bar Control, a Start Button and a Stop Button.The...
0
by: thesti | last post by:
hello, i have some jbuttons in my frame. and i have a recursive method, which will check a certain condition and if satisfied, will move one of the jbuttons location to somewhere else in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.