Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleShell a program with a specific startup directory
DescriptionThis example shows how to Shell a program with a specific startup directory in Visual Basic 6.
KeywordsShell, run, startup directory, start in
CategoriesWindows, 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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated