2017-08-02 15 views
0

ファイルを1つの場所から移動してユーザーのデスクトップに配置し、フォルダを抽出し、デスクトップのショートカットをexeファイルに作成するスクリプトがあります。 IDLEからスクリプトを実行すると、うまく動作します。 exeを実行すると、以下のスクリプトからpyinstallerでexeファイルを作成すると、管理者パスワードを尋ねます。私の会社では、PCに対する管理者特権はありません。誰でも管理者パスワード要求の原因を教えてもらえますか?Pyinstaller exeファイルが管理者パスワードを要求しています

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

PyInstallerがexeファイルを作成すると、管理者権限で自動的に開くことができます。 py2exeやcx_Freezeのようなものを使わなければならないので、そうする必要はありません!

+0

しかし、ショートカットを作成しているexeファイルは同じ方法で作成されており、管理者権限は必要ありません。だからこそ、私はそれがプログラムがやっていることだと思ったのです。私はpy2exeを試してみます – mickNeill

+0

あなたがpythonを使用する場合3はcx_Freezeを行います。あなたがそれらを設定する方法に応じてショートカットを使うと、admin privlagesは必要ありません。 – James

+0

@PatrickONeillあなたはそれを働かせましたか?もしそうなら、将来の人々がこの問題を解決できるように私の答えを正しいものとしてマークしてください! – James

関連する問題