Obtain Start-Up Directory

vb6 Mexico
  • 13 years ago

    Any ideas how to obtain the original start-up directory from VB6.

    i.e. If an .exe has a shortcut to it, is there a way to obtain the original starting directory (the directory that the shortcut sits in)? 

  • 13 years ago

    Can you clarify which folder you actually want to identify?

    If your EXE physically sits in a folder called  C:\MYAPP

    then the startup folder is normally C:\MYAPP


    A shortcut can exist that starts the program  C:\MYAPP\THEAPP.EXE but sets the working directory to be something else.. eg  C:\

     The shortcut itself may reside on the Desktop.

    And if your app is on a network, the drive letters in the shortcut may not be the same as the drive letter of the network drive 'as seen by' the app.


    So, Do you want to know where the application exists, where the shortcut exists, or where the shortcut tells the app to start from?




  • 13 years ago

    For example:

    My VB Application sits in C:\Source

    My Shortcut Sits in C:\Source\test\

    I want my VB App to be able to pull out the directory of the shortcut (C:\source\test) preferrably through command line argument (ie using Command$). Is there a way to either:

    a) Automatically pull this out using VB

    b) Setup the shortcut so that it passes as an argument the current directory that it started in (eg MyApp.exe c:\source\test) 

  • 13 years ago

    Have managed to solve the problem myself by using this in the shortcut:

     cmd /c MyApp.exe %cd%

     I can then extract the current directory from the command line arguments.

    Thanks for the help anyway

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity.” - Dennis Ritchie