Results 1 to 5 of 5

Thread: [RESOLVED] Opening VB .NET application from other VB .NET application

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    204

    Resolved [RESOLVED] Opening VB .NET application from other VB .NET application

    Hello,

    I would like to open VB .NET application from other VB .NET application by clicking form button.
    This is the code that I use:

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If IO.File.Exists("c:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\My Application\My Application\bin\Debug\My Application.exe") Then
                System.Diagnostics.Process.Start("c:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\My Application\My Application\bin\Debug\My Application.exe")
    
    Else
                MsgBox("My Application.exe file was not found")
    End If
        End Sub
    After clicking the button, "My Application" start form opens, but it has very limited functionality – some forms inside the application can’t be opened.

    If I open My Application.exe in a normal way (through Windows Explorer), it works fine.

    May be I am using wrong command to open application?

  2. #2
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: Opening VB .NET application from other VB .NET application

    In this case you must also set the directory from which the process starts. I don't know when exactly this is needed but I guess it has something to do with multifile applications.
    Code:
            If IO.File.Exists("c:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\My Application\My Application\bin\Debug\My Application.exe") Then
    
                Dim myProcess As New Process
    
                myProcess.StartInfo.FileName = ("c:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\My Application\My Application\bin\Debug\My Application.exe")
    
                myProcess.StartInfo.WorkingDirectory = "c:\Documents and Settings\User\My Documents\Visual Studio 2005\Projects\My Application\My Application\bin\Debug"
    
                myProcess.Start()
                
            Else
                MsgBox("My Application.exe file was not found")
            End If
    VB 2005, Win Xp Pro sp2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    204

    Re: Opening VB .NET application from other VB .NET application

    Thanks Half,
    it works perfect.

    One more question.

    If I put both applications in the same folder, how to set WorkingDirectory of the second application to Application Directory of the first?

  4. #4
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: Opening VB .NET application from other VB .NET application

    'Application.StartupPath' gives you the path to the dir where the original exe is. Use myProcess.StartInfo.WorkingDirectory = Application.StartupPath
    VB 2005, Win Xp Pro sp2

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2006
    Posts
    204

    Re: Opening VB .NET application from other VB .NET application

    Thanks Half

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width