Silent Install of PDFCreator 1.2.3 with separate GhostScript

This is what we currently use to install PDFCreator silently with a separate GhostScript Installation. Tested with Windows 7 and Windows Server 2008 R2:


@Rem Unattended setup of pdfcreator
@Rem 2010-2012 by patrick [at] freeclimbers.ch
@Rem Various inspirations from the web
@Rem Use freely at your own risk

@Rem Install latest PDFCreator with or w/o included GhostScript (as defined in PDFCreator.inf)
@Rem Use Text replace to enable use of system variables (%ProgramFiles%)

@Rem First check and eventually uninstall previous versions
if exist "%ProgramFiles%\\GhostScript\\uninstgs.exe" "%ProgramFiles%\\GhostScript\\uninstgs.exe" /S
start /w "Installing latest GhostScript" %~dp0gs905w32.exe /S /D=%ProgramFiles%\\GhostScript
if exist "%ProgramData%\\Microsoft\\Windows\\Start Menu\\Programs\\GhostScript" rmdir /s /q "%ProgramData%\\Microsoft\\Windows\\Start Menu\\Programs\\GhostScript"

@Rem First check and eventually uninstall previous versions
if exist "%ProgramFiles%\\pdfcreator\\unins000.exe" "%ProgramFiles%\\pdfcreator\\unins000.exe" /SILENT

@Rem This doesn't work currently (Browser Bar gets installed)
@Rem start /w "Installing latest PDF Creator" %~dp0PDFCreator-1_2_3_setup.exe /LANG=german /NOICONS /SP- /NORESTART /SILENT /NOCANCEL /DIR="%ProgramFiles%" /COMP program,helpfiles,helpfiles\\german,languages,languages\\german

@Rem as we cannot specify %ProgramFiles% in inf-file, we replace it...
if exist %tmp%\\pdfcreator.inf del %tmp%\\pdfcreator.inf
for /f "tokens=*" %%a in (%~dp0pdfcreator.inf) do call :AddText "%%a"

@Rem Then we can install PDF Creator specifying inf-file
start /w %~dp0PDFCreator-1_2_3_setup.exe /LOADINF=%tmp%\\PDFCreator.inf /SP- /NORESTART /SILENT
if exist %tmp%\\pdfcreator.inf del %tmp%\\pdfcreator.inf

@Rem cleanup Toolbar installer
if exist "%ProgramFiles%\\PDFCreator\\Toolbar" rmdir /s /q "%ProgramFiles%\\PDFCreator\\Toolbar"

exit /b

:AddText %1
set Text=%~1%
if "%Text%"=="Dir=[ReplaceMe]" (
echo Dir=%ProgramFiles%\\PDFCreator >> %tmp%\\pdfcreator.inf
) else (
echo %Text% >> %tmp%\\pdfcreator.inf
)
exit /b


This is the pdfcreator.inf file:

[Setup]
Lang=german
Dir=[ReplaceMe]
Group=PDFCreator
NoIcons=1
Toolbar=0
SetupType=custom
Components=program,languages,languages\\german
Tasks=
Printername=PDFCreator
ServerInstallation=0
Win9xPrinterdriver=0
WinNtPrinterdriver=0
Win2k32bitPrinterdriver=0