Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » Visual Basic (VB 4/5/6) » General Visual Basic » Open External Program and Wait Until it is...


Open External Program and Wait Until it is...Expand / Collapse
Author
Message
Posted 9/22/2008 11:09:46 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/22/2008 9:08:09 PM
Posts: 3, Visits: 4
Hello all...

I am trying to write a quick little file that will do the following:

On Form Load launch another program "C:\Windows\Notepad.exe"
Then go in to a wait status
When Notepad.exe is closed, Unload Me.

I am having trouble with the wait and unload piece. It launches the program and then does nothing else.

Any help would be great.
Post #25754
Posted 9/22/2008 7:28:30 PM
Forum Member

Forum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum MemberForum Member

Group: Forum Members
Last Login: 10/25/2008 11:59:43 AM
Posts: 72, Visits: 370
I'm confused about what you are asking.  Why open a seperate form to open Notepad.  Just use:    Shell "C:\Windows\Notepad.exe", vbNormalFocus
and close It when you are finished. 
Post #25760
Posted 9/22/2008 9:08:32 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/22/2008 9:08:09 PM
Posts: 3, Visits: 4
Thanks for the input, but "Notepad" was an example.

I was able to figure this issue out.

Post #25761
Posted 9/23/2008 1:28:28 PM


Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: Yesterday @ 4:36:16 PM
Posts: 1,463, Visits: 3,400
Welcome to A1vbcode gbargsley

I've just read the same type of question here

Keith

http://www.martin2k.co.uk/forums/

I've been programming with VB for 12 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.
Post #25768
Posted 9/23/2008 2:03:26 PM
Forum God

Forum GodForum GodForum GodForum GodForum GodForum GodForum GodForum God

Group: Forum Members
Last Login: Today @ 4:38:01 AM
Posts: 886, Visits: 5,287
I know you found a solution but here is a simple way of doing it.

Private Sub RunAppAndWait(ByVal AppPath As String)
Dim wshShell

    Set wshShell = CreateObject("WSCript.shell")
    wshShell.run AppPath, 5, True
    Set wshShell = Nothing
End Sub

Private Sub Form_Activate()
    MsgBox "Exiting"
    Unload Me
End Sub

Private Sub Form_Load()
    RunAppAndWait "Notepad.exe"
End Sub
Post #25769
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Brian, Peter

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 6:15am