Link to home
Start Free TrialLog in
Avatar of sasdaniels
sasdaniels

asked on

VBS Script to create shortcut to folder

Hi this is a script I used for an exe (someone helped me!), it creates a folder on desktop ok, but, I get the what program do you want to use prompt - funnily enough if I pick Internet Explorer it does open the folder. So maybe I need to associate the .lnk with explorer.exe in some way ? Possible in objShortCut.Arguments ? (thats leftover/unused script at moment . .)

Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("AllUsersDesktop")

Set objShortCut = objShell.CreateShortcut(strDesktopFolder & "\Manuals & Procedures.lnk")
objShortCut.TargetPath = """W:\Office Manual"""                                           '<-- only the executable
'objShortCut.Arguments =" -pf s:\config\help.pf -basekey INI -ininame s:\config\help.ini -T ""%TEMP%"""    '<-- argument stored in here
objShortCut.Description = "Manuals & Procedures"
objShortCut.IconLocation = "C:\WINDOWS\system32\SHELL32.dll, 19"
objShortCut.Save
ASKER CERTIFIED SOLUTION
Avatar of EDDYKT
EDDYKT
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sasdaniels
sasdaniels

ASKER

Thanks EDDYKT

Maybe I didn't explain clearly - there's no exe it's a short cut to a folder only, but, script doesn't associate the object with explorer . .
Thanks EDDYKT
I put "c:\windows\explorer.exe" in objShortCut.TargetPath
and """W:\Office Manual"""  in objShortCut.Arguments
Thus
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("AllUsersDesktop")

Set objShortCut = objShell.CreateShortcut(strDesktopFolder & "\Manuals & Procedures.lnk")
objShortCut.TargetPath = "c:\windows\explorer.exe"                                           '<-- only the executable
objShortCut.Arguments ="""W:\Office Manual"""    '<-- argument stored in here
objShortCut.Description = "Manuals & Procedures"
objShortCut.IconLocation = "C:\WINDOWS\system32\SHELL32.dll, 19"
objShortCut.Save