[wpkg-users] Creating a Folder in the Start Menu together with WPKG installed Program

Rainer Meier r.meier at wpkg.org
Wed May 25 20:09:00 CEST 2011


Hi Mikhail,

On 25.05.2011 10:49, Mikhail Joseph Salviejo wrote:
> OpenOffice.org 3.3 folder on Start Menu -> Programs
> 
> it must be inside
> 
> Start Menu -> Programs -> Documentation
> 
> where it would look like this
> 
> Start Menu -> Programs -> Documentation -> OpenOffice.org 3.3

There are two ways of achieving this:
- Modify the installer or use existing parameters to place the shortcuts in the
  desired folder automatically.
- Move shortcuts right after installation.


> it must be a part of the openoffice.xml rather than moving it manually due to
> numbers of computer here roughly around 300 units.

Of course. Such things have to be done automatically. Always.

So for the first option (customizing installation) this can be probably achieved
using Orca and creating an MST template which you pass then to msiexec during
silent installation (e.g. 'msiexec /qn /iopenoffice33.msi TRANSFORMS=ooo.mst').


I personally usually go for a simple post-install script which is doing the
requested modifications after installation.

A post-install script for OpenOffice.org might look as follows:

--- BEGIN postinstall.cmd ---

@echo off
:: Windows Vista
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto winVista7
:: Windows 7
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto winVista7

if exist "%ALLUSERSPROFILE%\Start Menu" goto en
goto de

:en
set MENU_FOLDER=Start Menu
set MENUBASE=%ALLUSERSPROFILE%\%MENU_FOLDER%
set F_PROGRAM=Programs
set F_DOC=Documentation
goto moveShortcuts

:de
set MENU_FOLDER=Startmenü
set MENUBASE=%ALLUSERSPROFILE%\%MENU_FOLDER%
set F_PROGRAM=Programme
set F_DOC=Dokumentation
goto moveShortcuts

:winVista7
set MENUBASE=%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu
set F_PROGRAM=Programs
set F_DOC=Documentation
goto moveShortcuts

:moveShortcuts
:: move shortcuts
mkdir "%MENUBASE%\%F_DOCUMENTATION%"
attrib -s -h -r "%MENUBASE%\%F_PROGRAM%\OpenOffice.org 3.3"
move /Y "%MENUBASE%\%F_PROGRAM%\OpenOffice.org 3.3" "%MENUBASE%\%F_DOC%"

exit /b 0

--- END postinstall.cmd ---

Note: Unfortunately Microsoft has decided to name the folders differently for
different language editions. So you need to detect the correct locations. The
script will support English an German but you can easily extend it to recognize
more languages if you have more.
For Windows Vista and 7 you don't need language-specific folders as the system
internally is always using English folder names - so this will work on all
Vista/7 language editions.

The "moveShortcuts" part is the same for all systems. It makes sure the target
folder exists and moves the OpenOffice.org folder there.

NOTE: OpenOffice sets some attributes on the folder, these need to be removed
before you can easily move the folder - that's why the attrib line is there.


So now what about package remove. Should you ever want to remove the package you
would probably like to remove the folder from the Documentation folder again.
The uninstall of OpenOffice.org will not remove it as the uninstaller does not
find it in the Documentation folder. So make sure to include a post-remove
script too:

--- BEGIN postremove.cmd ---

@echo off
:: Windows Vista
ver | findstr /i "6\.0\." > nul
IF %ERRORLEVEL% EQU 0 goto winVista7
:: Windows 7
ver | findstr /i "6\.1\." > nul
IF %ERRORLEVEL% EQU 0 goto winVista7

if exist "%ALLUSERSPROFILE%\Start Menu" goto en
goto de

:en
set MENU_FOLDER=Start Menu
set MENUBASE=%ALLUSERSPROFILE%\%MENU_FOLDER%
set F_PROGRAM=Programs
set F_DOC=Documentation
goto removeShortcuts

:de
set MENU_FOLDER=Startmenü
set MENUBASE=%ALLUSERSPROFILE%\%MENU_FOLDER%
set F_PROGRAM=Programme
set F_DOC=Dokumentation
goto removeShortcuts

:winVista7
set MENUBASE=%ALLUSERSPROFILE%\Microsoft\Windows\Start Menu
set F_PROGRAM=Programs
set F_DOC=Documentation
goto removeShortcuts

:removeShortcuts
:: remove shortcuts
rd /s /q "%MENUBASE%\%F_DOC%\OpenOffice.org 3.3"

exit /b 0

--- END postremove.cmd ---



Looks pretty easy. Now let's create a package for WPKG:

<?xml version="1.0" encoding="utf-8" ?>
<packages>

<package id='OpenOffice' name='Open Office' revision='321' priority='50'
reboot='false' >
  <!-- Open Office free office suite -->
  <check type='uninstall' condition='exists' path='OpenOffice.org 3.3' />
  <install cmd='msiexec /qn /i "%SOFTWARE%\OOo\openofficeorg33.msi"' />
  <install cmd='"%SOFTWARE%\OOo\postinstall.cmd"' />
  <remove cmd='msiexec /qn /x "%SOFTWARE%\OOo\openofficeorg33.msi"' />
  <remove cmd='"%SOFTWARE%\OOo\postremove.cmd"' />
  <upgrade cmd='msiexec /qn /i "%SOFTWARE%\OOo\openofficeorg33.msi"' />
  <upgrade cmd='"%SOFTWARE%\OOo\postinstall.cmd"' />
</package>

</packages>


So that's it basically. You might also think about switching to LibreOffice ;)


br,
Rainer



More information about the wpkg-users mailing list