I am not able to create one file executable with UAC.
Here is the project I am trying to add the UAC window - https://github.com/pywinauto/SWAPY
python27 latest-pyinstaller\pyinstaller.py --uac-admin -F swapy-ob.py
Single exe file does not ask for Admin rights.
With -D works fine, since the manifest placed near the exe.
I've tried Python 2.7.x 32/64bit, PyInstaller from the master/develop/pip - it did not help.
Test pyinstaller\tests\old_suite\interactive\test_onefile_win32_uac_admin.py passed but produced an exe file without UAC request.
# -*- mode: python -*-
block_cipher = None
a = Analysis(['swapy-ob.py'],
pathex=['PATH\\swapy'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=None,
runtime_hooks=None,
excludes=None,
win_no_prefer_redirects=None,
win_private_assemblies=None,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='swapy-ob',
debug=False,
strip=None,
upx=True,
console=True , uac_admin=True)
PS: I've read previous related issues, #853, etc.
Does UAC work with just simple helloworld app?
@codewarrior0 Do you have an idea how could we test the old test test_onefile_win32_uac_admin.py in appveyor?
Just test it as other interactive tests - check if it keeps running for a period of time - supposing that it's waiting for the user to permit admin access?
Does not work with simple helloworld.
I noticed a strange behavior, if I take the manifest file from helloworld\build\helloworld\ and place it near the onefile exe - UAC does not work(both has the same name, I expect it would). But if rename the exe and the manifest from the original name to a some the same name - UAC works properly.
For instance to helloworld1.exe and helloworld1.exe.manifest.
Rename back to the original name - does not work.
It is strange. It looks like the exe has broken embedded manifest, and it start work only if I rename from the original name and place a new manifest. But ResHaker shows no embedded manifest in the onefile exe.
PATH\pyinstaller>pyinstaller.py -F --uac-admin helloworld.py
174 INFO: PyInstaller: 3.0
175 INFO: Python: 2.7.10
176 INFO: Platform: Windows-7-6.1.7601-SP1
And the latest develop works for you?
@matysek, I have one idea how to deal with UAC in the tests.
I've just checked when UAC window is open I cannot catch it ;-) but I still can deal with UAC's accompanying windows. On my Win7 when UAC starts i see two new windows with classes:
I can check the behavior on appveyor CI tomorrow.
import time
import pywinauto
app = pywinauto.application.Application()
old_windows = set(pywinauto.findwindows.find_windows(top_level_only=False, visible_only=False))
while True:
new_windows = set(pywinauto.findwindows.find_windows(top_level_only=False, visible_only=False))
difference = new_windows.difference(old_windows)
if difference:
print 'New windows'
for nwh in difference:
nw = app.window_(handle=nwh)
print nw.Texts()
print nw.Class()
time.sleep(1)
else:
pass
old_windows = new_windows
time.sleep(0.1)
@matysek
And the latest develop works for you?
Unfortunately no.
Have just update to SHA-1: 93d25e563e49f88f5977afd9b6e26cb34bfb5efa
Do you have an idea how could we test the old test
test_onefile_win32_uac_admin.pyin appveyor?
I'll take a look at reviving this test.
I've got a hunch about what's happening here. It's a catch-22.
UAC options in the manifest only take effect if it is automatically loaded by Windows. The manifest automatically loaded by Windows cannot specify the MSVCRT libs because the onefile app needs to extract them to a tempdir. The MSVCRT libs must be specified in the manifest marked as "process default". Any manifest automatically loaded by Windows becomes the "process default". Thus, the onefile app does not include a manifest that will be automatically loaded, and instead explicitly loads it with the WinAPI while passing a flag that marks it as the "process default" manifest.
Here is a very simple reproduction of the same symptom (i.e. UAC does not work with onefile):
pyi-makespec --onefile helloworld.py
pyinstaller --uac-admin helloworld.spec
Any helloworld.py will do. A useful one in this case might be:
import ctypes
print ctypes.windll.shell32.IsUserAnAdmin()
I'm using pyinstaller version 3.1. What's going on? There doesn't seem to be any manifest embedded in helloworld.exe at all.
Any help appreciated.
Any update on this issue?
Also have the issue with onefile option. I can check the compiled exe with Sigcheck -m and it shows no manifest. It still works in folder mode.
I also tried using the --manifest but it seems to be simply ignored.
Same issue here, the uac_admin=True works fine when used with the COLLECT, but permission is not asked when in onefile mode.
I found a workaround although I don't know exactly why it worked :smile:
If you use pyinstaller --onefile --uac-admin my_app.py It will create a .spec file without COLLECT right? So I will add this below that .spec file, build again with that .spec file and I get a my_app folder with an exe file and a manifest file :smiley:
coll = COLLECT(exe,
strip=False,
upx=True,
name='my_app'
)
p/s: Don't forget uac_admin=True in exe = EXE .... :smile:
Test on: Windows 8.1 64bit, python 2.7.11 64 bit, pyinstaller 3.1.1
The current solution is using develop version of pyinstaller. Works fine for me.
I've just tried the develop version (3.3.dev0+d25657e), but to no avail. No admin rights are asked when producing a onefile executable.
Strange, I'm fine with it. This is my spec file:
block_cipher = None
a = Analysis(['connector_source.py'],
pathex=['*path*'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='connector',
debug=False,
strip=False,
upx=True,
console=False , uac_admin=True, icon='icon.ico')
coll = COLLECT(exe,
strip=False,
upx=True,
name='connector)
Seems very similar to mine:
block_cipher = None
a = Analysis(['bednetstick.py'],
pathex=['E:\bednetstick'],
binaries=[],
datas=[('data','.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='bednetstick',
debug=False,
strip=False,
upx=True,
console=False , uac_admin=True)
I have the same issue with python 3.5 (x64) and latest windows.
Is there a working fix?
I tried with almost any recent python2 and python3 releases on my win10 and nothing works!
Are you working on a fix?
I have the same issue on python 2.7 pyinstaller 3.1.1 on windows 7
Had the same Problem on CPython 3.4 with PyInstaller 3.2. Installed the dev tip and it worked.
pip uninstall PyInstaller
pip install git+https://github.com/pyinstaller/pyinstaller.git@develop
So I actually ended up finding a work around for this. On any new install, instead of installing the latest version, I just install 3.0 and UAC works fine.
From: Niklas Rosenstein notifications@github.com
Sent: Thursday, 8 December 2016 1:11:30 AM
To: pyinstaller/pyinstaller
Cc: Ashley Jackson; Manual
Subject: Re: [pyinstaller/pyinstaller] UAC not working in onefile again, migrate old UAC test (#1729)
Had the same Problem on CPython 3.4 with PyInstaller 3.2. Installed the dev tip and it worked.
pip uninstall PyInstaller
pip install git+https://github.com/pyinstaller/pyinstaller.git@develop
-
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/pyinstaller/pyinstaller/issues/1729#issuecomment-265472300, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMM4hZNaybYegsKwbq78AgBsTiWKYwQTks5rFsyigaJpZM4G27Bg.
@NiklasRosenstein I installed develop and it stll don't work
was there a version that works ?
Interestingly enough, I am still using Pyinstaller 3.0.
Haven't been bothered checking with latest releases.
This is with building in latest 2.7 and 3.6.
Does not work with win 8.1 and python 3.5. As pyinstaller==3.0, as develop version with helloworld example. Does not request privileges.
Hey there! Currently having this problem using windows 10, python 2.7.14, and pyinstaller version 3.3.1. Any update on when this will be fixed?
The solution ia very simple, your executable needs manifest file in its working directory. The manifest file is being generated by pyinstaller when generating executable. Search for it, place it to your executable and enjoy.
Thanks @FalcoSK ! So does that mean that there isn't a way though to generate a truly one-file executable with UAC prompt? It would always need this manifest file?
On a sidenote: I haven’t used Pyinstaller in a long time, however I would wager a bet that you could still use V 3.0, and still get a OneFile that doesn’t require a manifest file.
When I initially figured this out, I just gave up on newer versions.
From: Stephen Lewis Bianamara [mailto:[email protected]]
Sent: Thursday, 17 May 2018 9:27 AM
To: pyinstaller/pyinstaller pyinstaller@noreply.github.com
Cc: Ashley Jackson ajack_94@hotmail.com; Manual manual@noreply.github.com
Subject: Re: [pyinstaller/pyinstaller] UAC not working in onefile again, migrate old UAC test (#1729)
Thanks @FalcoSKhttps://github.com/FalcoSK ! So does that mean that there isn't a way though to generate a truly one-file executable with UAC prompt? It would always need this manifest file?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com/pyinstaller/pyinstaller/issues/1729#issuecomment-389697083, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMM4hXjC1zbdDtYoGqBIZv1ioePQdja1ks5tzLXcgaJpZM4G27Bg.
Unfortunately version 3.0 doesn't have --add-data support. It looks like this was added in 3.2.1. However, I have the same uac admin bug on version 3.2.1
This SO post seems relevant: Someone shows how to edit pyinstaller source to accept an input manifest file. Could this code change be committed?
@stevielb To be honest, I have no much knowledge about manifest files in windows. However, I think it should be side by side with the application so OS knows the basic information how to handle the application. Therefore if it is bundled in the application itself it makes no sense if the application is not somehow standard and familiar for windows. I mean pyinstaller is some kind of very "raw" tool to create "fake" exe files. The exe file itself decompress its context and then just launch python with your python code. So it is not standard win32 application. So OS needs to know something like: "hey there, I am a non-standard garbage, just let me elevate to admin and do whatever I want".
I used pyinstaller like a year ago for the last time, but I was fine with the manifest file as all my applications were bundled to installer (innosetup) and included also other files needed to run (configs, manifest, dlls, etc.).
My innosetup config for example. In addition, not related to this topic, I always include msvcr100.dll to my application so it can decompress itself even if client doesn't have runtime files (often happens even in 2018)
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "xxxxxxxxxxx"
#define MyAppVersion "1.3"
#define MyAppPublisher "xxxxxxxxxxx"
#define MyAppExeName "connector.exe"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{xxxxxxxxxxx}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
OutputDir=C:\_temp
OutputBaseFilename=xxxxxxxxxxx
SetupIconFile=C:\_temp\main.ico
Compression=lzma
SolidCompression=yes
PrivilegesRequired=admin
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:\_temp\dist\connector.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\_temp\build\connector\connector.exe.manifest"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\_temp\msvcr100.dll"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{commonprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
Hi @FalcoSK , Thanks for the tip and demonstration on how to use innosetup, and the tip on msvcr100.dll. That might be a really good way to go! I'll check in out and see if it could meet my project's needs.
To your point on the manifest, it is possible to embed the manifest file straight into the executable, which is what I was after. This can be done from the commandline using a windows tool called "mt". But in this case, it isn't the end result pyinstaller exe which needs the embedded manifest, it is the one which is launched after pyinstaller does it's unzipping of contents and kicks off process running the application Perhaps they actually are the same process. When I tried using mt to directly embed the manifest, it did not work.
I also was not able to successfully use my exe after using mt.exe to embed the manifest.
I'm downgrading to pyinstaller 3.0, but this issue needs some attention.
Hello guys, I'm a bit disappointed: There seems to be (nearly) nobody understanding the cause of the issue and nobody seems to be willed to provide a pull-request. Instead there are rumors, links to hacks valid for a 5-year-outdated version, etc.
Is there no Windows developer out there able to solve this? Come on guys!
Most helpful comment
I have the same issue on python 2.7 pyinstaller 3.1.1 on windows 7