【发布时间】:2011-03-03 12:16:47
【问题描述】:
我正在尝试在 Windows 7 机器(64 位)上从 vb.net 代码创建桌面快捷方式。以下代码可在 XP 上运行,但在 Win7 上运行时,我只会收到一条消息,指出应用程序已停止运行:
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()
有什么想法或更好的方法可以从 Win7 机器上的代码创建快捷方式?
【问题讨论】:
标签: c# .net vb.net windows-7 shortcut