|
|
Title | Shell a program with a specific startup directory |
Description | This example shows how to Shell a program with a specific startup directory in Visual Basic 6. |
Keywords | Shell, run, startup directory, start in |
Categories | Windows, Files and Directories, Software Engineering |
|
|
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
|
|
For an example that you can Shell with this program, see the HowTo Display the program's current directory.
|
|
|
|
|
|