I would like to be able to create a folder shortcut programmatically but I can't achieve it.
I'm asking for help to VB experts. I would like to do it by vbscript. For precision a folder
shortcut is a shortcut that opens to the directory it points to when we double-click on it.
I need to make it works on windows vista and windows seven.
With my researches I was able to create a shortcut to an .exe with this code :
Dim Shell, DesktopPath, lnk
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
Set lnk = Shell.CreateShortcut(DesktopPath & "\Vlc.lnk")
lnk.TargetPath = "C:\Program Files\VideoLAN\VLC\vlc.exe"
lnk.Save
It works fine without any problem but it's a shortcut to a file. If I change the instruction
lnk.TargetPath = "C:\Program Files\VideoLAN\VLC\vlc.exe"
with
lnk.TargetPath = "C:\Program Files\VideoLAN\VLC"
it doesn't create a folder shortcut as I was expecting
On the web I found someone explaining that to do that I need a folder with the file desktop.ini in it:
[.ShellClassInfo]
CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}
Flags=2
And also a shortcut file target.lnk created with the command
Dim Shell, lnk
Set Shell = CreateObject("WScript.Shell")
Set lnk = Shell.CreateShortcut("c:\shortcut_folder\target.lnk")
lnk.TargetPath = "C:\Program Files\VideoLAN\VLC"
lnk.Save
and then apply this command to the folder
attrib +s c:\shortcut_folder
It didn't work and it seems complex to me just to create a folder shortcut.
It would be great help a script working for what I want
Good weekend and thank you for reading.
This post has been edited by anirelles: 04 February 2012 - 07:10 AM

New Topic/Question
Reply




MultiQuote



|