stephenlecomptejr
asked on
Need help with vbscript to create shortcut on desktop-refuses to run cause of correct syntax error.
I'm trying to create a shortcut automatically using vbs script but it refuses to run all the way through because it throws a char: 2 error - object doesn't support this property or method which happens on this particular line item:
WshShell = CreateObject("Wscript.shel l")
Please note attachment that shows error.
I took this code from this website but it hasn't worked out for me.
https://support.microsoft.com/en-us/help/244677/how-to-create-a-desktop-shortcut-with-the-windows-script-host
WshShell = CreateObject("Wscript.shel
Please note attachment that shows error.
I took this code from this website but it hasn't worked out for me.
https://support.microsoft.com/en-us/help/244677/how-to-create-a-desktop-shortcut-with-the-windows-script-host
Public Sub CreateIconToDesktop()
Dim WshShell
Dim strDesktop
Dim oMyShortCut
WshShell = CreateObject("Wscript.shell")
strDesktop = WshShell.SpecialFolders("Desktop")
oMyShortcut = WshShell.CreateShortcut(strDesktop + "\Sample.lnk")
'oMyShortcut.WindowStyle = 3 &&Maximized 7=Minimized 4=Normal
oMyShortcut.IconLocation = "Q:\Dialer\_dbadmin\icons\logocampaign.ico"
oMyShortcut.TargetPath = "Q:\Dialer\dialercampaigns.accdb"
'oMyShortCut.Hotkey = "ALT+CTRL+F"
oMyShortCut.Save
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dude you the man! Thank you so much.
Welcome, glad that helped.
~bp
~bp
One thing I do see wrong if a stand alone VBS, you need a Set when assigning object variables, like:
Set WshShell = CreateObject("Wscript.shel
»bp