[wpkg-users] Remove problem, wpkg checks success before remove completes

Rainer Meier r.meier at wpkg.org
Wed Apr 8 16:27:31 CEST 2009


Hi Mike,

Mike Moynihan wrote:
> I am having a problem with the wpkg.js checking for the status of the
> remove, before the remove completes. 
> This is a simple package, it's the one used in the WPKG QUICK INSTALL
> guide.  The remove command runs as a separte process, returning control
> back to wpkg.js before it has completed.  This causes the issue, as
> wpkg.js checks the install status immediately after the uninstall
> command returns control.
>  
> Is there a command switch that will cause the uninstaller to not return
> control until it completes?  Is there a way for wpkg to handle this?
>  
> I execute wpkg.js in a batch file via windows job scheduler.  Here is
> the info regarding the job, including the debug info written to the log.
>  
> wpkg.bat:
> set software=\\server\software
> cscript \\server\wpkg\wpkg.js <file://\\server\wpkg\wpkg.js>
> /synchronize /debug > c:\wpkg.log
>  
> Package for DIA:
>   <package id='dia' name='Dia Diagram Editor' revision='1'
> reboot='false' priority='800'>
>     <check type='file' condition='exists'
> path='%PROGRAMFILES%\dia\dia-0.96.1-9-uninstall.exe'/>
>     <install cmd='"%SOFTWARE%\dia\dia-setup-0.96.1-9.exe" /S'/>
>     <upgrade cmd='"%SOFTWARE%\dia\dia-setup-0.96.1-9.exe" /S'/>
>     <remove cmd='"%PROGRAMFILES%\dia\dia-0.96.1-9-uninstall.exe" /S'/>
>   </package>


Strictly speaking this is not a WPKG issue but one of the uninstall tool. For
such cases I wrote a generic wrapper script which kicks in the uninstaller and
then waits for it to get removed for a maximum of 30 seconds. If it does not
complete, it exits with non-zero exit code. Just save it as
"unattended-uninstall.cmd" (or any other name) and call it as your remove
command instead of calling dia-uninstaller directly.

You might want to have a look at Bugzilla entry 149 where I posted an attachment
which contains generic install/uninstall wrappers which work for most of the
applications. The script example below is used for VLC as well (where the
uninstaller behaves oddly too.

<http://bugzilla.wpkg.org/show_bug.cgi?id=149>


@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 exissts 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%\dia

:: Path to the uninstaller (see path definition above)
set UNINSTALLER=%APP_DIR%\dia-0.96.1-9-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