Page 1 of 1
[SOLVED] killalltasks does not kill running tasks
Published: February 15, 2023 - 5:21 PM
by brice73
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
Re: killalltasks is not killing running tasks
Published: February 16, 2023 - 6:07 PM
by dcardon
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
Re: killalltasks is not killing running tasks
Published: February 17, 2023 - 1:13 PM
by brice73
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
Re: killalltasks is not killing running tasks
Published: February 17, 2023 - 2:27 PM
by dcardon
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
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
Re: killalltasks is not killing running tasks
Published: February 17, 2023 - 2:44 PM
by brice73
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,
Re: killalltasks is not killing running tasks
Published: February 17, 2023 - 4:27 PM
by dcardon
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
Re: killalltasks is not killing running tasks
Published: February 23, 2023 - 6:07 PM
by brice73
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.
Re: killalltasks is not killing running tasks
Published: February 24, 2023 - 09:42
by dcardon
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
Re: [SOLVED] killalltasks is not killing running tasks
Published: February 26, 2023 - 2:30 PM
by brice73
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,