Py2Exe: avoid windows to request permission to exe

2019-08-07 16:16发布

问题:

I have a py2exe-built program which is executed directly from the console (Windows Powershell). Involved modules are: xlrd and PrettyTable.

Unfortunately, each time the program is called, Windows asks the user for a confirmation, as the program would need particular privileges.

This is undesirable as the script is "safe" for the system. It just gets text files as arguments and outputs a text file, in the same folder. I don't want the user to be scared by this permission request.

Is there any way to avoid such behaviour?

回答1:

It may be possible; usually the reason for an executable requiring admininstrator or privileges or special permissions in newer versions of Windows is that it modifies something in your file system. Since your using an Excel File Module, your are probably accessing the hard drive, which worries the system because it thinks your application might mess with something important. (Like what malware, viruses and other junk does) But since its not installing anything executable, this Stackoverflow question might have your answer:

(if you have access to a Manifest File)

Stack Overflow Question

Otherwise, there might be nothing you can do about it, as Windows is just built that way



回答2:

It seems that I have found an answer by myself with the help of this answer, linked by this answer. The issue was also connected to this other question. A common cause generated two different but related problems.

It is caused by the .exe file name. Switching to a different file name, stops the UAC to ask for admin privileges (and executes the software in the same shell, which solves the other question).

The name was:

<project_name_under_NDA>_update.exe

But switching to

try.exe

It worked.