Shortcut to folder

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Philo
    Forum Member
    • Feb 2004
    • 78

    Shortcut to folder

    Hi All,

    Ive got a simple problem while trying to create a shortcut to open a folder on the local hard drive.

    I use the following code

    Code:
    Shell.CreateShortcut(Shell.GetFolder(SHF_DESKTOP), "Routefinder Networks", first_hdd.."\\RouteFinder Networks\\", "", "", _WindowsFolder .. "\\explorer.exe", 1, SW_SHOWNORMAL);
    The shortcut gets created but when clicked on a dialog box appears and says windows cannot open files of this type please select an application to open the file. If I manually pick explorer.exe it opens up great.

    I have also discovered if I right click on the shortcut and go to properties and add an extra \ to the path it is automatically removed by windows but the shortcut then starts working correctly.

    Any ideas? Am I doing something stupid?
  • csd214
    Forum Member
    • Oct 2001
    • 939

    #2
    What I experienced:

    Your code worked well! (WinXP Pro SP2).

    You don't need the trailing (double) slash for the folder. "\\RouteFinder Networks" works fine (if the folder exists). The variable 'first_hdd' has to be assigned a valid value, of course.

    Sorry, I can't tell you WHY you have problems!

    Comment

    • Philo
      Forum Member
      • Feb 2004
      • 78

      #3
      hmm its strange,

      I got it working by changing the code to:

      Code:
      Shell.CreateShortcut(Shell.GetFolder(SHF_DESKTOP), "Routefinder Networks", first_hdd.."RouteFinder Networks", "", first_hdd.."RouteFinder Networks", _WindowsFolder .. "\\explorer.exe", 1, SW_SHOWNORMAL);
      I didnt realise I had to set the working folder option as well to get it to work.

      Comment

      • csd214
        Forum Member
        • Oct 2001
        • 939

        #4
        Now your code does not work on my side! You have removed both the leading slash and the trailing slash from target folder. Then I had to add a trailing slash to first_hdd.

        At the first test I had:
        first_hdd = "D:"
        and Target in Shell.CreateShortcut = first_hdd.. "\\RouteFinder Networks"

        Solution #2:
        first_hdd = "D:\\"
        Target in Shell.CreateShortcut = first_hdd.. "RouteFinder Networks"

        Both examples build D:\ RouteFinder Networks at runtime and work with and without a working folder. It's hard to understand that the working folder should have any significance; but it does not hurt.

        Glad you found a working solution.

        Comment

        Working...
        X