Difference between revisions of "Vlc"
Line 1: | Line 1: | ||
+ | == Simple method == | ||
+ | |||
This is the package for [http://www.videolan.org/vlc/ VLC (Video LAN Client)], a multimedia player. | This is the package for [http://www.videolan.org/vlc/ VLC (Video LAN Client)], a multimedia player. | ||
Line 23: | Line 25: | ||
Upgrade is also possible, but then the installer asks (not silently) to remove the old version - so it is needed to insert two <upgrade /> statements: one for remove the old one (as <remove /> above) and one for install it (as <install /> above). | Upgrade is also possible, but then the installer asks (not silently) to remove the old version - so it is needed to insert two <upgrade /> statements: one for remove the old one (as <remove /> above) and one for install it (as <install /> above). | ||
+ | |||
+ | |||
+ | == Advanced method by SkyBeam == | ||
+ | VLC is a bit tricky because upgrading (installation if an installed version is already installed) is not fully unattended. It interactively asks the user if the existing version should be uninstalled first. As already mentioned above a solution would be to remove the previous version first before installing the VLC update. However also this fails since uninstall.exe forks a new process while the parent exits immediately. So if this happens too quickly then the install program still asks for confirmation. | ||
+ | |||
+ | So I did a small workaround for that: | ||
+ | <pre> | ||
+ | <?xml version="1.0" encoding="utf-8" ?> | ||
+ | <packages> | ||
+ | |||
+ | <package id='VLC' name='VLC media player' revision='864' priority='50' reboot='false' > | ||
+ | <!-- VLC media player --> | ||
+ | <check type='uninstall' condition='exists' path='VideoLAN VLC media player 0.8.6d' /> | ||
+ | <install cmd='"%SOFTWARE%\VLC v.0.8.6d\unattended.cmd"' /> | ||
+ | <remove cmd='"%SOFTWARE%\VLC v.0.8.6d\unattended-uninstall.cmd"' /> | ||
+ | <upgrade cmd='"%SOFTWARE%\VLC v.0.8.6d\unattended.cmd"' /> | ||
+ | </package> | ||
+ | </packages> | ||
+ | </pre> | ||
+ | |||
+ | I am using these scripts (unattended.cmd, unattended-uninstall.cmd) because they need to perform some more actions. Here are the contents: | ||
+ | |||
+ | unattended.cmd | ||
+ | <pre> | ||
+ | @echo off | ||
+ | |||
+ | set BINARY=vlc-0.8.6d-win32.exe | ||
+ | |||
+ | echo Installing VLC media plyer | ||
+ | |||
+ | set INSTALLER_LOC=%~dp0 | ||
+ | set EXIT_CODE=0 | ||
+ | set PROG_FILES=%ProgramFiles% | ||
+ | if not "%ProgramFiles(x86)%" == "" set PROG_FILES=%ProgramFiles(x86)% | ||
+ | |||
+ | echo - Removing previous version "%INSTALLER_LOC%unattended-uninstall.cmd" | ||
+ | call "%INSTALLER_LOC%unattended-uninstall.cmd" | ||
+ | |||
+ | start /wait "VLC" "%INSTALLER_LOC%%BINARY%" /S /NCRC /D="%PROG_FILES%" | ||
+ | set EXIT_CODE=%ERRORLEVEL% | ||
+ | |||
+ | call "%INSTALLER_LOC%cleanup.cmd" | ||
+ | |||
+ | exit /B %EXIT_CODE% | ||
+ | </pre> | ||
+ | |||
+ | As you can see it calls unattended-uninstall.cmd prior to installation (any time!). The evaluation of PROG_FILES assures that it installs the 32-bit VLC player always to the correct program files directory also on 64-bit systems. | ||
+ | |||
+ | unattended-uninstall.cmd | ||
+ | <pre> | ||
+ | @echo off | ||
+ | |||
+ | echo Removing VLC media plyer | ||
+ | |||
+ | set INSTALLER_LOC=%~dp0 | ||
+ | set UNINSTALLER=VideoLAN\VLC\uninstall.exe | ||
+ | set OPTIONS=/S | ||
+ | set PROG_FILES=%ProgramFiles% | ||
+ | if not "%ProgramFiles(x86)%" == "" set PROG_FILES=%ProgramFiles(x86)% | ||
+ | |||
+ | if not exist "%PROG_FILES%\%UNINSTALLER%" goto end | ||
+ | start /wait "VLC uninstall" "%PROG_FILES%\%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 | ||
+ | REM Get sleep.exe from the Windows Resource Kit Tools | ||
+ | for /L %%C IN (1,1,30) DO ( | ||
+ | if not exist "%PROG_FILES%\%UNINSTALLER%" goto end | ||
+ | "%INSTALLER_LOC%sleep.exe" 1 | ||
+ | ) | ||
+ | |||
+ | :end | ||
+ | </pre> | ||
+ | |||
+ | As this script is called by unattended.cmd also when VLC is probably not installed it first checks if there is an uninstallation to be done. If not it just skips. | ||
+ | |||
+ | As I wrote above the uninstaller forks a child process and exits immediately. So there is a need to wait for the uninstaller to complete. I am simply checking if the uninstaller still exists. If yes I wait for another second. | ||
+ | |||
+ | NOTE: You need to put "sleep.exe" to the same folder where unattended-uninstall.cmd is installed. The binary can be obtained from the Windows Resource Kit Tools package which is free for download at the Microsoft web page. | ||
+ | |||
+ | In order to prevent an endless-loop the uninstallation will stop after a maximum of 30 seconds. | ||
+ | |||
+ | This has been tested on Windows Vista x64. | ||
[[category:Silent Installers]] | [[category:Silent Installers]] |
Revision as of 11:35, 28 December 2007
Simple method
This is the package for VLC (Video LAN Client), a multimedia player.
The second install command removes the desktop shortcut (the path may have to be changed to a localized name).
<?xml version="1.0" encoding="UTF-8"?> <packages> <package id="vlc" name="Video LAN Client" revision="1" reboot="false" priority="0"> <check type="uninstall" condition="exists" path="VideoLAN VLC media player 0.8.4a" /> <install cmd='"%SOFTWARE%\vlc\vlc-0.8.4a-win32.exe" /S' /> <install cmd='%CMD% /c del "%ALLUSERSPROFILE%\Desktop\VLC media player.lnk"' /> <remove cmd='"%PROGRAMFILES%\VideoLAN\VLC\uninstall.exe" /S' /> </package> </packages>
Upgrade is also possible, but then the installer asks (not silently) to remove the old version - so it is needed to insert two <upgrade /> statements: one for remove the old one (as <remove /> above) and one for install it (as <install /> above).
Advanced method by SkyBeam
VLC is a bit tricky because upgrading (installation if an installed version is already installed) is not fully unattended. It interactively asks the user if the existing version should be uninstalled first. As already mentioned above a solution would be to remove the previous version first before installing the VLC update. However also this fails since uninstall.exe forks a new process while the parent exits immediately. So if this happens too quickly then the install program still asks for confirmation.
So I did a small workaround for that:
<?xml version="1.0" encoding="utf-8" ?> <packages> <package id='VLC' name='VLC media player' revision='864' priority='50' reboot='false' > <!-- VLC media player --> <check type='uninstall' condition='exists' path='VideoLAN VLC media player 0.8.6d' /> <install cmd='"%SOFTWARE%\VLC v.0.8.6d\unattended.cmd"' /> <remove cmd='"%SOFTWARE%\VLC v.0.8.6d\unattended-uninstall.cmd"' /> <upgrade cmd='"%SOFTWARE%\VLC v.0.8.6d\unattended.cmd"' /> </package> </packages>
I am using these scripts (unattended.cmd, unattended-uninstall.cmd) because they need to perform some more actions. Here are the contents:
unattended.cmd
@echo off set BINARY=vlc-0.8.6d-win32.exe echo Installing VLC media plyer set INSTALLER_LOC=%~dp0 set EXIT_CODE=0 set PROG_FILES=%ProgramFiles% if not "%ProgramFiles(x86)%" == "" set PROG_FILES=%ProgramFiles(x86)% echo - Removing previous version "%INSTALLER_LOC%unattended-uninstall.cmd" call "%INSTALLER_LOC%unattended-uninstall.cmd" start /wait "VLC" "%INSTALLER_LOC%%BINARY%" /S /NCRC /D="%PROG_FILES%" set EXIT_CODE=%ERRORLEVEL% call "%INSTALLER_LOC%cleanup.cmd" exit /B %EXIT_CODE%
As you can see it calls unattended-uninstall.cmd prior to installation (any time!). The evaluation of PROG_FILES assures that it installs the 32-bit VLC player always to the correct program files directory also on 64-bit systems.
unattended-uninstall.cmd
@echo off echo Removing VLC media plyer set INSTALLER_LOC=%~dp0 set UNINSTALLER=VideoLAN\VLC\uninstall.exe set OPTIONS=/S set PROG_FILES=%ProgramFiles% if not "%ProgramFiles(x86)%" == "" set PROG_FILES=%ProgramFiles(x86)% if not exist "%PROG_FILES%\%UNINSTALLER%" goto end start /wait "VLC uninstall" "%PROG_FILES%\%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 REM Get sleep.exe from the Windows Resource Kit Tools for /L %%C IN (1,1,30) DO ( if not exist "%PROG_FILES%\%UNINSTALLER%" goto end "%INSTALLER_LOC%sleep.exe" 1 ) :end
As this script is called by unattended.cmd also when VLC is probably not installed it first checks if there is an uninstallation to be done. If not it just skips.
As I wrote above the uninstaller forks a child process and exits immediately. So there is a need to wait for the uninstaller to complete. I am simply checking if the uninstaller still exists. If yes I wait for another second.
NOTE: You need to put "sleep.exe" to the same folder where unattended-uninstall.cmd is installed. The binary can be obtained from the Windows Resource Kit Tools package which is free for download at the Microsoft web page.
In order to prevent an endless-loop the uninstallation will stop after a maximum of 30 seconds.
This has been tested on Windows Vista x64.