Create shortcut from vb.net on Windows 7 box (64 bit)
Posted
by Matt
on Stack Overflow
See other posts from Stack Overflow
or by Matt
Published on 2010-06-14T12:47:17Z
Indexed on
2010/06/14
13:42 UTC
Read the original article
Hit count: 899
I am trying to create a desktop shortcut from vb.net code on a Windows 7 box (64 bit). The following code works on XP, but when run on Win7 I just get a message stating the App has stopped working:
Imports IWshRuntimeLibrary
Dim WshShell As WshShellClass = New WshShellClass
Dim MyShortcut As IWshRuntimeLibrary.IWshShortcut
' The shortcut will be created on the desktop
'Win 7
MyShortcut = CType(WshShell.CreateShortcut("C:\Users\Public\Desktop\iexplore.lnk"), IWshRuntimeLibrary.IWshShortcut)
'MyShortcut = CType(WshShell.CreateShortcut("C:\Documents and Settings\All Users\Desktop\iexplore.lnk"), IWshRuntimeLibrary.IWshShortcut)
MyShortcut.TargetPath = "C:\Program Files\Internet Explorer\iexplore.exe" 'Specify target app full path
MyShortcut.Description = "IE"
MyShortcut.Save()
Any thoughts or better ways to create a shorcut from code on a Win7 box?
© Stack Overflow or respective owner