January 30th, 2003, 07:23 PM
Launching another exe from a different directory
I am trying to launch a separate executable in a controlled development environment using the Shell Function from a VB 6.0 application located in a different directory.
For discussion's sake, let me define a few items:
My VB application = MyVB.exe
My Target app = Target.exe
Because this is a controlled dev environment, I cannot simply move MyVB.exe into the TargetDir; it must reside in a separate directory.
Normally, Shell works fine. However, this particular case, my Target.exe has relative links in it. When I run my app from my VBDir, all of the Target.exe's relative links are wrong and Target.exe barfs.
Does anyone know how to launch another executable from within a VB app where the "Start in" directory is correctly set to the Target.exe's?
January 30th, 2003, 09:33 PM
What is the exact command that you are using to execute the command with Shell()?
January 31st, 2003, 09:51 AM
Here's the code. I've changed the exe & dir names to match my example above, but this is otherwise identical to what I run:
MyPath = "C:\TargetDir\Target.exe"
RetVal = Shell(MyPath, vbNormalFocus)
January 31st, 2003, 10:30 AM
I think what you are looking for is SetCurrentDirectory
Public Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long