0

I am facing a problem i.e. when I install my python application using an NSIS and install it for "anyone using this computer" and after the installation when I open the application nothing is happening as it should prompt the UAC to continue with administration access but it is not happening and I have to right click the application, only then I can run it as administrator I have tried many ways like including "RequestExecutionLevel Admin" in nsis script and also tried to include the manifest file to keep the requestedExecutionLevel level as "asInvoker" as I was expecting a UAC prompt to be triggered to get access of the administrator, but none are working. Any insights or suggestions on how to prompt the UAC elevation dialog when launching the application would be very helpful.

Attached is the logs from application run when run with double click

Traceback (most recent call last):
  File "C:\Program Files (x86)\Discovery App\Discovery_App.launch.pyw", line 34, in <module>
    from Handlers.AppMain import main
  File ".\AppMain.py", line 5, in <module>
  File ".\DiscoveryHandler.py", line 52, in <module>
  File "C:\Program Files (x86)\Discovery App\pkgs\paramiko\util.py", line 255, in log_to_file
    f = open(filename, "a")
PermissionError: [Errno 13] Permission denied: 'C:\\Program Files (x86)\\Discovery App\\pkgs\\Handlers/paramiko.txt'

1 Answers1

0

If you have RequestExecutionLevel Admin in your .nsi then the installer will be UAC elevated and any process you start from the installer with Exec/ExecWait will be elevated as well. Things started with ExecShell might be elevated (a .exe will, other filetypes might not).

If your application does not elevate when you start it from the Start Menu then it is lacking a manifest.

Now that you have edited your question we can see that it is Python. Unless you are shipping your own python.exe, you cannot use a manifest.

Your options are perhaps:

A) Use a custom launcher application .exe that finds and calls python.exe.

B) Elevate inside Python.

Anders
  • 97,548
  • 12
  • 110
  • 164
  • Here we are using bundled python and not the python installed in the system. The shorcut application which is created is pointing to the python launcher and that launcher points to the .exe file .Can you help me with the steps like how to include the manifest for this so that UAC prompt is visible when installed for anyuser when double clicked on the application shortcut.I also tried with the Elevate inside python which you have mentioned above but still the issue is not resolved – VAIBHAV S S Jul 24 '23 at 17:35
  • I manifest will work, make sure the .exe does not already have a manifest because the internal resource manifest will override external file manifests. Check with Resource Hacker. Beyond this, you are not really asking about NSIS anymore so I can't really help... – Anders Jul 24 '23 at 19:54