答案1
AStackOverflow 答案展示了如何在 Powershell 中实现这一点。没有简单的界面来添加Run as administrator
标志,因此它涉及在二进制文件中翻转一个位.LNK
。
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\7-Zip File Manager.lnk")
$Shortcut.TargetPath = "C:\Program Files\7-Zip\7zFM.exe"
$Shortcut.Save()
$bytes = [System.IO.File]::ReadAllBytes("$Home\Desktop\7-Zip File Manager.lnk")
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes("$Home\Desktop\7-Zip File Manager.lnk", $bytes)