Sunday, April 20, 2014

Installation Script for GhostScript

#This script must be run with admin privledges
#This script downloads and installs ghostscript which is used to convert PDF files to images. 
$Date = [System.datetime]::now.ToString("yyyy-MM-dd")
$Junk = "$Home\Junk$Date"
if(!$(Test-Path $Junk)) { $void = New-Item -ItemType directory -Path $Junk }

#Create a programming folder in our Home directory if it doesn't exist.
$pgmDirectory = "$Home" + "\programming"
if(!$(Test-Path $pgmDirectory)) { $void = New-Item -ItemType directory -Path $pgmDirectory }

#If the TessNet language pack is not downloaded yet, download and extract it.
$gsDirectory = $pgmDirectory + "\GhostScript"
if(!$(Test-Path $gsDirectory)) {
    Write-Host "Downloading GhostScript"
    $webclient = New-Object System.Net.WebClient
    $file = "$Junk\gs914w64.exe"
    $webclient.DownloadFile($url,$file)
    Start-Sleep -Seconds 2
    Write-Host "Download complete, now installing GhostScript"

    & "$Junk\gs914w64.exe" "/S" "/NCRC" "/D=$gsDirectory"
    Start-Sleep -Seconds 2
    Write-Host "GhostScript is installed, now cleaning up downloaded files."

}
else {
    Write-Host "GhostScript has already been installed" 
}

Remove-Item $Junk -Force -Recurse -ErrorAction SilentlyContinue

<#
#Run this commented out section to uninstall GhostScript.  
#This uninstalled assummes that you have it installed in the same directories this script installed it to. 
$unstlDirectory = "$Home" + "\programming" + "\GhostScript"
& "$unstlDirectory\uninstgs.exe "  "/S" "/NCRC"
Remove-Item $unstlDirectory -Force -Recurse
#>

No comments:

Post a Comment