[wpkg-users] remove checks too quickly

Rainer Meier r.meier at wpkg.org
Mon Apr 16 19:19:05 CEST 2012


Hi Sebastian,

On 16.04.2012 16:06, Sebastian Elsner wrote:
> using the foobar2000 package from the wiki (http://wpkg.org/Foobar2000) I had a
> strange problem. After removing the package from the profile, wpkg.js reported
> that the package could not be removed. But all the files were uninstalled
> corectly when I checked in explorer.

Foobar is using (in)famous NSIS installer/uninstaller. The uninstaller is known 
to fork a sub-process which terminates the parent process before the actual 
uninstallation is completed. Some users report that in some cases appending "_?" 
command lline parameter will exit the parent only after the specified folder has 
been removed. However sometimes this seems not to work either.

So you might try adding the following to your command line:
_?=%ProgramFiles%\foobar2000

> It took me a while to find out that wpkg.js
> would check too quickly before the system had actually erased the files
> (probably because the uninstaller process would return too quickly) .

It's actually not WPKG checking too early, it's the uninstaller terminating 
before it's job has been finished.

> So I added
> a new remove command right after the actual command which would just silently
> ping some machine and the remove succeeded... is this a known issue or is there
> some setting I can change to make wpkg wait a second or two before checking?

Adding a "sleep" command might look like a decent work-around. However I 
strongly recommend not to go for this option. The required sleep timeout is 
hardly predictable and depending on machine speed and load it might be much 
longer or shorter. I prefer clean uninstallers or a script which is waiting a 
variable amount of time (either until uninstallation completes or until timeout, 
whatever comes first).


Try the following script for foobar2000 uninstall. Save it to any script name 
like "uninstall.cmd" and then call this script instead of the uninstaller 
(uninstall.exe) directly. The script works for most NSIS uninstallers which 
behave wrongly - inlcuding VLC.

@echo off

:: This script is an extended uninstaller script for programs which have tricky
:: uninstallers (e.g. VLC media player).
:: It is able to run an uninstaller application and then to monitor if the
:: uninstaller is erased from the system. Depending on the result (either
:: remove completes or timeout occurs) it exits with different ecit code:
:: code 0: all fine, program uninstalled
:: code 1: failed, uninstaller still exists after timeout


:: This is required to evaluate the target of %ProgramFiles% on 64-bit systems
:: Please note that this is required only if you uninstall a 32-bit application.
set PROGRAM_FILES=%ProgramFiles%
if not "%ProgramFiles(x86)%" == "" set PROGRAM_FILES=%ProgramFiles(x86)%

:: Path where the uninstaller is located
set APP_DIR=%PROGRAM_FILES%\foobar2000

:: Path to the uninstaller (see path definition above)
set UNINSTALLER=%APP_DIR%\uninstall.exe

:: Options to be passed to the uninstaller in order to uninstall silently
set OPTIONS=/S


:: ############################################################################
:: No need to change anything below this line (usually ;-))
:: ############################################################################
echo Removing Program

if not exist "%UNINSTALLER%" goto good_end
start /wait "Uninstall" "%UNINSTALLER%" %OPTIONS%
REM Unfortunately the uninstaller seems to fork a child process and the parent
REM process exits immediately. So give it some time to uninstall
for /L %%C IN (1,1,30) DO (
   if not exist "%UNINSTALLER%" goto good_end
   ping -n 2 127.0.0.1 > NUL
)
:bad_end
exit /B 1

:good_end
if exist "%APP_DIR%" rmdir /s /q "%APP_DIR%"
exit /B 0



More information about the wpkg-users mailing list