Python Forum
chnage icon advanced properties !!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
chnage icon advanced properties !!
#1
hello all ...
is there anyway to check this box for the icon by python ?

[Image: admin-3.png]
[Image: Cmd-shortcut-run-as-administrator-checkbox.png]
Reply
#2
And why, do you wish to do this ?????
Reply
#3
(Sep-30-2018, 11:33 AM)Larz60+ Wrote: And why, do you wish to do this ?????

im coding a tool that create a shortcut for a program that needs administrator privileges....
anyway i found a code that can do that by powershell ...

this is the code :
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$Home\Desktop\ColorPix.lnk")
$Shortcut.TargetPath = "C:\Program Files (x86)\ColorPix\ColorPix.exe"
$Shortcut.Save()

$bytes = [System.IO.File]::ReadAllBytes("$Home\Desktop\ColorPix.lnk")
$bytes[0x15] = $bytes[0x15] -bor 0x20 #set byte 21 (0x15) bit 6 (0x20) ON
[System.IO.File]::WriteAllBytes("$Home\Desktop\ColorPix.lnk", $bytes)
Quote:In short, you need to read the .lnk file in as an array of bytes. Locate byte 21 (0x15) and change bit 6 (0x20) to 1. This is the RunAsAdministrator flag. Then you write you byte array back into the .lnk file.

In your code this would look like this:


how i can do the same via python ??
Reply
#4
solved by @Lanting from stackoverflow

code :
filename = r'C:\Users\root\Desktop\qassam.lnk'
with open(filename, "rb") as f2:
  ba = bytearray(f2.read())
  ba[0x15] = ba[0x15] | 0x20
with open(filename, "wb") as f3:
  f3.write(ba)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020