[SOLVED] killalltasks does not kill running tasks

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

February 15, 2023 - 5:21 PM

Good morning,

I have a problem with the function killalltasks which does not allow processes to be terminated during a package installation.

In the def install() function of a portable software package (Phyloboite.exe), the application's executable is launched with the following command:

Code: Select all

run('C:\AppsPortables\Phyloboite\Phyloboite.exe')
The application launches (in Windows XP Service Pack 3 compatibility mode as recommended by the compatibility wizard) and the installation script continues, but the `killalltasks` command (still within `def install()`) then fails to close the application. Furthermore, the `isrunning` function applied to each task does not return "True".

The global variable taskstokill is defined in setup.py as follows:

Code: Select all

taskstokill= ['Phyloboite.exe','_Phylo00.exe']
and the killalltasks function is called like this:

Code: Select all

killalltasks(taskstokill,include_children=True)

However, opening the task manager clearly shows the execution of the two processes 'Phyloboite.exe' and '_Phylo00.exe', and by manually opening a DOS command prompt window, it is possible to manually kill these two tasks.

The problem might be related to the compatibility mode which launches the installation in full screen and makes you lose control of everything else (taskbar, start button...)?

WAPT Enterprise 2.3.0.13505
WAPT server running Ubuntu 20.04
Package administration/creation under Windows 10
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 16, 2023 - 6:07 PM

Hi Brice,

To better isolate the problem:
* Could you try killing it from a PyScripter to see if it's a context issue?
* Could you try killing it from a command prompt with `taskkill /f /im myprogram.exe`?

Thanks,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

February 17, 2023 - 1:13 PM

Hello Denis,

The Phyloboite.exe program, when executed, launches the _Phylo00.exe process. I can indeed kill both processes by killing the child process _Phylo00.exe, either with a command prompt or in the PyScripter command-line interpreter using killalltasks. (To do this, however, I must go through the Task Manager, minimize the process which, once launched, occupies the entire screen and not a window, and then launch a command prompt or PyScripter).

The main problem is that the portable application I want to deploy (Phyloboite.exe) requires administrator privileges to run. To resolve this, I created a registry key in the install() function so that all users can run the application with administrator rights and in compatibility mode with Windows XP SP3

Code: Select all

registry_setstring(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers","C:\AppsPortables\Phyloboite\Phyloboite.exe","~ RUNASADMIN WINXPSP3 RUNASINVOKER", type=REG_SZ)
The problem is that despite this, once the application is deployed on workstations, it is actually necessary to open the application once with an administrator account before users can themselves launch the application with administrator rights.

To bypass this UAC issue, I wanted to try opening and then closing the application during installation. After several attempts, and due to the inoperability of `killalltasks` in `install()`, I created an executable file (from a .bat file) that does this and is launched during installation (within the `install()` function). Installation/uninstallation tests using PyScripter show no particular problems; the application opens for a few seconds (3), then closes, and the installation completes. However, after a real-world deployment test with the machines shut down, the application installation fails to complete and seems to run indefinitely.

Do you have a solution to this problem of a portable application requiring administrator rights to be launched?

ps1: For your information, the .bat file from which the .exe file is created contains the following commands:

Code: Select all

start C:\AppsPortables\Phyloboite\Phyloboite.exe && timeout /t 3 && taskkill /f /im "_Phylo00.exe"


(ps2: another curious thing is that the killalltasks function does indeed kill the _Phylo00.exe process that is running during uninstallation when the uninstall() function is called).



Thank you in advance
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 17, 2023 - 2:27 PM

Hello Brice,

I don't have an answer to your problem, however as a possible avenue of investigation you should try installing it in a Local SYSTEM account, which is used by the WAPT agent on the machine to see how it behaves.

To perform the test, you can install the tis-sysinternals-pstools package and run

Code: Select all

psexec -s -i cmd.exe


Then perform the installation in this cmd.exe. A notable difference between the Local Administrator account and the Local System account is that Local System does not have a default desktop. This can cause some poorly written installers/software to malfunction.

Regarding the issue of launching as administrator, I advise you to check which files actually need to be read and write access for the software in question using a process explorer or equivalent, and to set the correct ACLs on the corresponding files/directories/registry keys.

Sincerely,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

February 17, 2023 - 2:44 PM

Hello Denis,

Thank you for your advice, which I will try to explore further.

While testing something else on the test machine, I just noticed that despite the WAPT agent not shutting down during the Phyloboite application installation (I ended up canceling the task after about ten minutes, as it was a package of less than 10 MB), it seems that the application installed correctly and I was able to launch it directly with a current user account. However, the package is still showing an error/needs install, and the WAPT agent does not shut down when the machine is turned off while the installation is running, so the installation and deployment procedure is not working...

Best regards,
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 17, 2023 - 4:27 PM

Hi Brice,

there's a timeout on the `run()` function which means that after a certain time it kills everything that was launched and returns an error code.

Regards,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

February 23, 2023 - 6:07 PM

Finally, the package installation worked; the .exe file opened and closed the application during installation, resolving the UAC issue. :) The package installation problem may have stemmed from a slow network connection on one of the test machines. The software was successfully deployed to numerous machines, and the few installation errors were easily resolved by restarting the program.
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

February 24, 2023 - 09:42

Hi Brice,

thanks for the feedback. Regarding the network slowness issue, do you mean that the installer connects to a network resource to complete the installation? If possible, it's recommended to use self-contained WAPT packages to avoid this kind of problem (i.e., having everything in the package). The WAPT agent downloads the packages and caches them during the day (every 1.5 hours) and installs them when the machine shuts down or when requested. This prevents network connectivity issues during installation.

I'm marking the topic as resolved.

Best regards,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

February 26, 2023 - 2:30 PM

Hello Denis,
Initially, I didn't check the package download box during the client update, and a test machine had a limited and very slow network connection. The first installation attempts failed. By enabling the package download and increasing the timeout (the one for the .exe file created from the batch file), and testing on another machine, the installation worked.
Regards,
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
Locked