News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

This example shows how to Shell a program with a specific startup directory

Started by nandagopal, Dec 10, 2008, 07:09 PM

Previous topic - Next topic

nandagopal

When a program uses Shell to start another program, the new program starts in the shelling program's currect directory, even if the shelled program is a shortcut that specifies its own startup path.

This program shells another application in a specific startup directory. It saves its current directory, uses ChDir to go to desired start directory, shells the otehr program, and then restores its original directory.


Private Sub cmdGo_Click()
Dim prev_dir As String

    ' Save the current directory.
    prev_dir = CurDir

    ' Go to the desired startup directory.
    ChDir txtStartupPath.Text

    ' Shell the application.
    Shell txtApplication.Text

    ' Restore the saved directory.
    ChDir prev_dir
    MsgBox CurDir
End Sub