#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Dallas, TX
    Posts
    135
    Rep Power
    12

    Question 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

    root
    |
    |_VBDir
    |___MyVB.exe
    |
    |_TargetDir
    |___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?

    Many thanks,
    Steve
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    What is the exact command that you are using to execute the command with Shell()?
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Dallas, TX
    Posts
    135
    Rep Power
    12
    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:

    Dim RetVal
    Dim MyPath

    MyPath = "C:\TargetDir\Target.exe"

    RetVal = Shell(MyPath, vbNormalFocus)
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    I think what you are looking for is SetCurrentDirectory


    Public Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

IMN logo majestic logo threadwatch logo seochat tools logo