将快捷方式添加到所有用户开始菜单



我在"所有用户"开始菜单(C:ProgramDataMicrosoftWindowsStart Menu)中创建快捷方式时遇到问题。

Set wsc = WScript.CreateObject("WScript.Shell")
Set lnk = wsc.CreateShortcut("C:ProgramDataMicrosoftWindowsStart MenuMy app.LNK")
lnk.targetpath = "C:Program Filesmy appmy  app.exe"
lnk.workingdirectory = "C:Program Filesmy app" 
lnk.save

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

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

相关内容

最新更新