Page 1 of 1

[SOLVED] Running Python script via setup.py

Published: November 28, 2025 - 10:29 AM
by Lazaare
Hello,

I'm developing a "Template-setup" package that would simply execute a Python script within setup.py (without installing any software or anything).
This script searches for differences between the package directory structure and the directory structure of software already installed on the user's machine and performs a simple "copyto" operation.
The problem is: when run locally via PyScripter, the script works perfectly with the paths correctly declared, etc. However, once uploaded as a package and deployed to the users' machines, it doesn't execute and returns an "error" in the package status.

Is this a problem with access rights, a checkbox, or simply the execution location?

Thank you in advance,
Best regards


, ----------
WAPTConsole Enterprise version 2.6.0.17392

Re: Running Python script via setup.py

Published: Dec 1, 2025 - 09:29
by florentR2
to test:
subprocess.Popen([r"C:\Program Files (x86)\wapt\waptpythonw.exe", makepath(basedir,'script_externe.py')])

Re: Running Python script via setup.py

Published: Dec 2, 2025 - 09:06
by Lazaare
Thank you for your reply, but I don't think that's it.
Let me explain: I'm trying to manipulate files/folders on the user's machine. This manipulation would be done via a script written in setup.py.
Apparently, something is blocking the initialization of the package uploaded to the machines :-/

In fact, I tested with a completely empty setup.py and... the package also reports an "ERROR" error.

Re: Running Python script via setup.py

Published: Dec 2, 2025 - 11:40 AM
by blemoigne
Hello,
what paths are being specified? Are they user paths?
Note that WAPT packages are installed under a system account, unlike PyScripter, which you likely need to run as administrator.

Have a good day,
Bertrand

Re: Running Python script via setup.py

Published: Dec 2, 2025 - 1:14 PM
by Lazaare
Hello,

I'm declaring the path as being inside "C:".
When you say it launches as a system account, is there a way to grant it privileges?

Thank you very much in advance.

Re: Running Python script via setup.py

Published: Dec 2, 2025 - 1:58 PM
by dcardon
Hello Lazarus,

As Bertrand mentioned, the Wapt agent runs under the machine's LOCAL SYSTEM account. There are some differences compared to running in a user session, notably the presence of a desktop or the various default file paths, and access to remote resources (SYSTEM has access to the machine account credentials, but not those of a user on the machine).

The rights are those of S-1-5-18 (NT Authority\System), which appears as "System" in an explorer on a French Windows system.

You can test your script by running it in PSExec to see the problem. The following command opens a shell as local system (you can install psexec with the tis-ms-pstools package); of course, it must be run with an account that has local admin rights and in a high-security environment.

Code: Select all

psexec -i -s cmd.exe
Sincerely,

Denis

Re: Running Python script via setup.py

Published: Dec 4, 2025 - 3:31 PM
by Lazaare
Hello,

thank you very much for your clarification. Indeed, the presence of the PStools package on a machine allows the execution of other Python scripts contained in other packages. This works perfectly.

You can mark the topic as "Resolved".

Thanks again,