0

我正在尝试使用 VBScript 创建用户桌面的快捷方式。但是,似乎我的代码中缺少某些内容,因为它试图将快捷方式放在错误的目录中,C:\desktop\My Scans 而不是 C:\Users\username\Desktop\My Scans.lnk

Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = (desktopPath & "\My Scans.LNK")
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.Save

知道我错过了什么吗?非常感谢您的帮助

4

1 回答 1

1

这似乎对我有用:

Set oWS = WScript.CreateObject("WScript.Shell")
' Get the %userprofile% in a variable, or else it won't be recognized
userProfile = oWS.ExpandEnvironmentStrings( "%userprofile%" )
sLinkFile = userProfile & "\desktop\My Scans.LNK"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.Save
于 2012-10-29T22:02:02.643 回答