|
-
Oct 5th, 2007, 08:57 AM
#1
Thread Starter
Addicted Member
[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?
-
Oct 5th, 2007, 01:59 PM
#2
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
-
Oct 5th, 2007, 04:20 PM
#3
Thread Starter
Addicted Member
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?
-
Oct 5th, 2007, 06:28 PM
#4
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
-
Oct 6th, 2007, 05:07 AM
#5
Thread Starter
Addicted Member
Re: Opening VB .NET application from other VB .NET application
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|