Super User Asked on January 1, 2022
In Windows I can set up a shortcut to run application always as administrator:
I need to create such shortcut from the command line. How can I do that?
try with shortcutJS.bat - it can create a shortcut with "run as admin" tick from command line :
call shortcutJS.bat -linkfile "some.lnk" -target "%cd%some.bat" -adminpermissions yes
this also changes 21st byte of the file. More information can be found somewhere in this docs.
Answered by npocmaka on January 1, 2022
A StackOverflow answer shows how to accomplish this in Powershell. There's no easy interface to add the Run as administrator
flag, so it involves flipping a bit in the .LNK
binary file.
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$HomeDesktop7-Zip File Manager.lnk")
$Shortcut.TargetPath = "C:Program Files7-Zip7zFM.exe"
$Shortcut.Save()
$bytes = [System.IO.File]::ReadAllBytes("$HomeDesktop7-Zip File Manager.lnk")
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes("$HomeDesktop7-Zip File Manager.lnk", $bytes)
Answered by davidmneedham on January 1, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP