Home All Groups Group Topic Archive Search About

.exe from within a form

Author
2 May 2006 11:36 PM
Al_C
Is there a control that permits me to run an exe file inside a form?
I've tried the process.start approach and it doesn;t seem to do what I
expected.  There doesn't seem to behave the way I expect (similar to a C
shell).
Two things happen.  The calling program seems to go into limbo if the
process.hasexited command works, and in some cases the hasexited command
results in a TRUE condtion even when the shelled app is still running.
Would like to run these exe's in a window so I can an employ a showdialog
method.
Thanks for any suggestions,
Al

Author
3 May 2006 12:03 AM
Al_C
The timer is enabled and unless I click on button1 the code works as
expected.
Once I click on button1, the code seems to shut of or ignore the
timer1_tick.
Soon as I close down the notoepad.exe the code starts working fine again
Thanks for you patience.
Al


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("notepad.exe")
myProcess.Start()
While (myProcess.HasExited = False)
End While
End Sub


Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Static Dim n As Int16
n = n + 1
Me.ProgressBar1.Value = n
If n = 100 Then
     n = 0
End If
End Sub

End Class





Show quoteHide quote
"Al_C" <acl***@bicnet.net> wrote in message
news:%23OxmbFkbGHA.1260@TK2MSFTNGP05.phx.gbl...
> Is there a control that permits me to run an exe file inside a form?
> I've tried the process.start approach and it doesn;t seem to do what I
> expected.  There doesn't seem to behave the way I expect (similar to a C
> shell).
> Two things happen.  The calling program seems to go into limbo if the
> process.hasexited command works, and in some cases the hasexited command
> results in a TRUE condtion even when the shelled app is still running.
> Would like to run these exe's in a window so I can an employ a showdialog
> method.
> Thanks for any suggestions,
> Al
>
>
>
Author
3 May 2006 12:53 PM
Göran_Andersson
The timer relies on windows messaging, if you use a "dead" loop like
that, you will lock up the messaging processing, and nothing happens
until you leave the loop.

Put a DoEvents call in the loop.

Al_C wrote:
Show quoteHide quote
> The timer is enabled and unless I click on button1 the code works as
> expected.
> Once I click on button1, the code seems to shut of or ignore the
> timer1_tick.
> Soon as I close down the notoepad.exe the code starts working fine again
> Thanks for you patience.
> Al
>
>
> Public Class Form1
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> Dim myProcess As New Process()
> Dim myProcessStartInfo As New ProcessStartInfo("notepad.exe")
> myProcess.Start()
> While (myProcess.HasExited = False)
> End While
> End Sub
>
>
> Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Timer1.Tick
> Static Dim n As Int16
> n = n + 1
> Me.ProgressBar1.Value = n
> If n = 100 Then
>      n = 0
> End If
> End Sub
>
> End Class
>
>
>
>
>
> "Al_C" <acl***@bicnet.net> wrote in message
> news:%23OxmbFkbGHA.1260@TK2MSFTNGP05.phx.gbl...
>> Is there a control that permits me to run an exe file inside a form?
>> I've tried the process.start approach and it doesn;t seem to do what I
>> expected.  There doesn't seem to behave the way I expect (similar to a C
>> shell).
>> Two things happen.  The calling program seems to go into limbo if the
>> process.hasexited command works, and in some cases the hasexited command
>> results in a TRUE condtion even when the shelled app is still running.
>> Would like to run these exe's in a window so I can an employ a showdialog
>> method.
>> Thanks for any suggestions,
>> Al
>>
>>
>>
>
>
Author
3 May 2006 5:13 AM
Cor Ligthert [MVP]
Al

Did you already try the waitforexit in the process class?

http://groups.google.com/group/microsoft.public.dotnet.languages.vb/msg/b011cea26cf6ba2a

I hope this helps,

Cor

Show quoteHide quote
"Al_C" <acl***@bicnet.net> schreef in bericht
news:%23OxmbFkbGHA.1260@TK2MSFTNGP05.phx.gbl...
> Is there a control that permits me to run an exe file inside a form?
> I've tried the process.start approach and it doesn;t seem to do what I
> expected.  There doesn't seem to behave the way I expect (similar to a C
> shell).
> Two things happen.  The calling program seems to go into limbo if the
> process.hasexited command works, and in some cases the hasexited command
> results in a TRUE condtion even when the shelled app is still running.
> Would like to run these exe's in a window so I can an employ a showdialog
> method.
> Thanks for any suggestions,
> Al
>
>
>
Author
4 May 2006 1:50 AM
Al_C
Want to thank you both.  You saved my biscuits in the last two days.
It was a combination of issues.
To start with, I did have the software in too tight a loop.  Adding a
doevents
(in .net speak it's application.doevents!)  solved the problem with well
behaved apps.
The other issue I had was with an app that had a .exe extension but would
produce a
..scr extension in the task manager.  This is the one that acted really
strange.  It would
say it had exited and it really did not.
Oddly all I had to do was to copy it to another filename with a .exe
extension and it fit
very neatly into the while !hasexited loop.  But this also lead to another
finding.  This app was
such a CPU hog,  I actually had to put my thread to sleep for 100ms so this
app could run.
Thank you all for your help.
The boss is happy, so I'm happy.  ;)
Al




Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OqH5GAnbGHA.3908@TK2MSFTNGP02.phx.gbl...
> Al
>
> Did you already try the waitforexit in the process class?
>
> http://groups.google.com/group/microsoft.public.dotnet.languages.vb/msg/b011cea26cf6ba2a
>
> I hope this helps,
>
> Cor
>
> "Al_C" <acl***@bicnet.net> schreef in bericht
> news:%23OxmbFkbGHA.1260@TK2MSFTNGP05.phx.gbl...
>> Is there a control that permits me to run an exe file inside a form?
>> I've tried the process.start approach and it doesn;t seem to do what I
>> expected.  There doesn't seem to behave the way I expect (similar to a C
>> shell).
>> Two things happen.  The calling program seems to go into limbo if the
>> process.hasexited command works, and in some cases the hasexited command
>> results in a TRUE condtion even when the shelled app is still running.
>> Would like to run these exe's in a window so I can an employ a showdialog
>> method.
>> Thanks for any suggestions,
>> Al
>>
>>
>>
>
>