1

C:\ProgramData\Microsoft\Windows\Start Menu我在“所有用户”开始菜单 ( )中创建快捷方式时遇到问题。

Set wsc = WScript.CreateObject("WScript.Shell")
Set lnk = wsc.CreateShortcut("C:\ProgramData\Microsoft\Windows\Start Menu\My app.LNK")

lnk.targetpath = "C:\Program Files\my app\my  app.exe"
lnk.workingdirectory = "C:\Program Files\my app" 
lnk.save
4

1 回答 1

1

我找到了解决方案,这里是需要添加的脚本,在快捷方式创建脚本之前

If WScript.Arguments.Named.Exists("elevated") = False Then
  'Launch the script again as administrator
  CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
  WScript.Quit
Else
  'Change the working directory from the system32 folder back to the script's folder.
  Set oShell = CreateObject("WScript.Shell")
  oShell.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
End If
于 2015-01-13T22:46:37.720 回答