Pyinstaller exe文件要求输入管理员密码

时间:2017-08-02 17:29:37

标签: python pyinstaller

我有一个脚本可以从一个位置移动文件并将其放在用户桌面上,提取文件夹并在桌面上创建一个到exe文件的快捷方式。当我从IDLE运行脚本时,它工作正常。一旦我用pyinstaller创建一个exe,从下面的脚本中,它会在你运行exe时询问管理员密码。在我的公司,我们的PC没有管理员权限。谁能告诉我什么会导致管理员密码请求?

import zipfile
import os
import winshell
import ctypes
import shutil


filepath = os.path.expanduser("~\Desktop\\")
srcFile = 'I:\Decoder\Decoder.zip'
shutil.copyfile(srcFile, filepath +'Decoder.zip')
if os.path.isfile(filepath +'Decoder.zip'):

    with zipfile.ZipFile(filepath +'Decoder.zip','r') as zip_ref:
        zip_ref.extractall(filepath+'Decoder')


    link_filepath = os.path.join(winshell.desktop(), "Decoder-Shortcut.lnk")
    with winshell.shortcut(link_filepath) as link:
        link.path = filepath+'Decoder\dist\Decoder\Decoder.exe'
        link.description = "Shortcut to Decoder"

    ctypes.windll.user32.MessageBoxA(0, "Decoder-shortcut has been added to your Desktop, Enjoy!", "Info", 1)

else:
    ctypes.windll.user32.MessageBoxA(0, "Please Copy the Decoder.zip file to the desktop.!", "Info", 1)

1 个答案:

答案 0 :(得分:1)

当PyInstaller生成exe文件时,它会自动使其只能以管理员权限打开。你必须使用像py2exe或cx_Freeze这样的东西,所以你不必这样做!

相关问题