installing Ghostscript silently

2.5k Views Asked by At

We've been installing Ghostscript by gs10011w64.exe /S for years. For some reason, the new release gs10011w64.exe (10.01.1) will not allow us to silently install with "/S". Has anyone found this too? Any way around this?

gs10011w64.exe /S

this should silently install the program, but the installation with the Next button appears

3

There are 3 best solutions below

0
triple-lariat On

Ghostscript no longer distributes their installers with a silent installation option as shown on their blog.

It seems their official position is that anyone who needs the install to be silent will have to modify the source themselves.

See also: discussion related to this issue on their bug tracker.

0
Ojutan On

well this is very unfortunately for anyone who downloads GS as part of it's prodcut setup.

Apart from that Ghostscript has the strange behavior that it does NOT install in the directory provided in the GUI setup, instead it creates a subfolder with it's version number.

We do have a "gs" subfolder and we did silently put a ghostscript 9.xx in there... and address it by gs\gswin32c.exe .... installing the GS10 straight into that gs subfolder doesn't work any more and even in 9.x it was only possible by passing the path to the setup.

GS was formerly designed to work as "side by side" till the 8.x versions so you can possibly just copy&paste the folder structure to a place where you want it... my second guess is they want more people to buy the Artifex commercial license.

0
shawn On

Simplest solution

While it's not really an installation in the sense that it runs the package and assigns any registry + uninstall entries, you can extract the installation package (gs10021w64.exe) to the target directory of your choice (preserving folder structure and overwriting existing files) using this command with 7-Zip (full) to the folder c:\destination\folder:

"%ProgramFiles%\7-Zip\7z.exe" x -y -o"c:\destination\folder" "gs10021w64.exe"

"Installation" notes

  • You must use the 7z.exe from an "installed" 7-Zip since the "portable" version doesn't support Nsis compression.
  • If you need it to be portable you can copy both the 7z.exe and 7z.dll files from a 7-Zip installation (of the appropriate bit-type) and use that.
  • The $PLUGINSDIR folder is part of the NSIS installation package and not part of GhostScript, as is the *.nsis file. You can either remove them afterwards or exclude them with the -x switch (-x!"$PLUGINSDIR" -x!"*.nsis").
  • You probably neither want nor require the MSVCRT package so you can exclude that as well (-x!"vcredist*"). The MSVCRT included in the installation package (for 10.02.1 anyway) is over two years old (v14.29.30135).
  • The license (included at the bottom of this post) specifically lists several included files and directories that are not covered by the AGPL or have other specific licensing requirements.
    • You can add -x!"Resource/CMap" to exclude them.
    • There is an exception for Identity-UTF16-H but I see no way to include a file from an excluded folder within the same 7z command so if you want it you will need to run a second command.
    • I don't see jpegxr anywhere in the current distribution so that statement in the license appears to be out of date.

With full exclusions of the non-GPL and a pathless copy of the installable 7-zip you can use these two commands to "install" to c:\destination\folder:

7z.exe x -y -x!"$PLUGINSDIR" -x!"*.nsis" -x!"vcredist*" -o"c:\destination\folder" "gs10021w64.exe"
7z.exe x -y -ir!"Identity-UTF16-H" -o"c:\destination\folder" "gs10021w64.exe"

Note that the exclamation mark (!) has special meaning in batch files with delayed expansion enabled (setlocal enableDelayedExpansion). If you're using this feature in your distribution then you may need to escape each exclamation point with two carets (^^!).

The registry

  • There are several records added to the registry during a standard installation, but these don't appear to be necessary if you're using the bin directory directly.
  • The installer adds a single default value to indicate the installation path at HKLM\SOFTWARE\Artifex\GPL Ghostscript\10.02.1 (where 10.02.1 is the current version).
  • The installer adds two REG_SZ values to HKLM\SOFTWARE\GPL Ghostscript\10.02.1 (where 10.02.1 is the current version).
    • GS_DLL has the full path to the gsdll64.dll file (I assume gsdll32.dll on 32-bit installers).
    • GS_LIB contains a semicolon-separated list of the full paths to the bin, lib and fonts directories, likely to ensure that when called from outside of the bin directory it will still be able to locate these resources.

You can mimic this behavior with the following commands:

reg.exe ADD "HKLM\SOFTWARE\Artifex\GPL Ghostscript\10.02.1" /ve /d "C:\destination\folder" /f 
reg.exe ADD "HKLM\SOFTWARE\GPL Ghostscript\10.02.1" /v "GS_DLL" /t REG_SZ /d "C:\destination\folder\bin\gsdll64.dll" /f 
reg.exe ADD "HKLM\SOFTWARE\GPL Ghostscript\10.02.1" /v "GS_LIB" /t REG_SZ /d "C:\destination\folder\bin;C:\destination\folder\lib;C:\destination\folder\fonts" /f

If you added these registry keys and values, then as you install/distribute newer versions you will need to remove the older versioned keys and replace them with new versioned keys to ensure it's up to date with the installed version. If you're using a static path then only the key names will need to be changed to the newer version.

Before adding any registry keys I recommend that you test in your environment to see if these are actually necessary. Chances are good they are not.

Path

One more thing the installer does that extraction alone does not is add the bin folder to the path environment variable. If you want this, you can use SETX for this to the bin directory. This sample checks if it exists in the path already and only adds it if it's not in there.

PATH | find /I "C:\destination\folder\bin" 1>NUL 2>NUL
IF "%ERRORLEVEL%"=="0" (
    ECHO. GS bin already in PATH.
) ELSE (
    ECHO. Adding GS bin to PATH.
    setx.exe -m PATH "%PATH%;C:\destination\folder\bin"
)

Before modifying the path please consider whether it is actually necessary. This will depend on your need, of course, but since there are regularly security vulnerabilities discovered in GhostScript you should minimize exposure.

Uninstall support

Finally, the last thing that the installer does that is not done by extracting or the commands above is add uninstall support. I personally have no interest in doing this and am not familiar enough with the Nsis package format to be able to provide much guidance. You would only need to reverse any changes you made (remove destination folder, registry keys, and PATH environment variable) so a few commands is all it should take.

The license agreement (for 10.02.1)

The files in the base, psi, lib, toolbin, examples, doc, man and iccprofiles directories (folders), and pcl, xps and gpdl directories (folders), if included, and any subdirectories (sub-folders) thereof are part of GPL Ghostscript.

The files in the Resource directory and any subdirectories thereof are also part of GPL Ghostscript, with the explicit exception of the files in the CMap subdirectory (except "Identity-UTF16-H", which is part of GPL Ghostscript). The CMap files are copyright Adobe Systems Incorporated and covered by a separate, Affero GPL compatible license.

Additionally, the font files (in Resource/Font) are distributed under the AGPL with the following exemption:

As a special exception, permission is granted to include these font programs in a Postscript or PDF file that consists of a document that contains text to be displayed or printed using this font, regardless of the conditions or license applying to the document itself.

The files under the jpegxr directory and any subdirectories thereof are distributed under a no cost, open source license granted by the ITU/ISO/IEC but it is not Affero GPL compatible - see jpegxr/COPYRIGHT.txt for details.

GPL Ghostscript is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

GPL Ghostscript is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program so you can know your rights and responsibilities. It should be in a file named doc/COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.