我正在尝试创建一个需要管理员权限的快捷方式。。。我在网上找到了这个代码,但它是在powershell中编码的。。。我测试它的工作!!但是我需要在python中使用python如何做同样的事情
powershell代码:
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.
$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)
这是我的python代码:
^{pr2}$我不知道下一步是什么你能帮我吗?在
您可以使用库来编辑
.lnk
文件(我没有检查):{e使用命令^模拟}的行为
此代码生成了快捷方式。但我不明白你到底想要什么。在
代码:
相关问题 更多 >
编程相关推荐