Pyinstaller 建立需要管理員權限的可執行文件

Pyinstaller 建立需要管理員權限的可執行文件

我正在嘗試將 python 腳本打包成可執行檔。可執行檔名稱中包含「update」一詞,產生的可執行檔需要 UAC 提升。我有一個清單文件,我嘗試讓 pyinstaller 產生正常的可執行文件,但它不起作用。

這是清單文件:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity name="firmware_updater" processorArchitecture="amd64" type="win32" version="1.0.0.0"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity language="*" name="Microsoft.Windows.Common-Controls" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" type="win32" version="6.0.0.0"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
          <requestedPrivileges>
              <requestedExecutionLevel
                  level="asInvoker"
                  uiAccess="false"
              />  
          </requestedPrivileges>
      </security>
  </trustInfo>
  <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

我用於 pyinstaller 的指令是:

pyinstaller --onefile --icon .\<filename>.ico --manifest .\<filename>.exe.manifest --exclude-module tkinter --exclude-module IPython .\<filename>.py

清單檔案與 python 腳本位於同一目錄中。

我正在使用 Python 2.7.16 和 Pyinstaller 3.4。

如何讓 pyinstaller 產生不需要提升的執行檔?

相關內容