echo "`n"
echo "INSTALLAZIONE DI PAPERCUT: STAMPANTE E CLIENT"
echo "{INSTALLATION OF PAPERCUT PRINTER AND CLIENT}"
echo "`n"

if(Get-Printer|findstr papercut){
	echo "Rimozione di una vecchia versione presente nel sistema..."
	echo "{Removing an old version on the system...}"
	echo "`n"
	Start-Process -FilePath "C:\Windows\System32\rundll32.exe" -ArgumentList "printui.dll,PrintUIEntry /dl /n `"papercut`" "
}

echo "Installazione del driver..."
echo "{Installing drivers...}"
echo "`n"
Start-Process -Wait -FilePath "C:\Windows\System32\rundll32.exe" -ArgumentList "printui.dll,PrintUIEntry /ia /f .\PCL6\OEMsetup.inf /m `"Kyocera TASKalfa 5054ci KX`" "

Start-Sleep -s 3
Restart-Service -Name spooler
Start-Sleep -s 3

echo "Installazione del programma client"
echo "{Installing client program}"
echo "`n"
Start-Process -Wait -FilePath ".\win\client-local-install.exe" -ArgumentList "/silent"

IF ($?) 
{ 
echo "Aggiunto il programma PaperCut Client"
echo "{PaperCut Client program added}"
echo "`n"
}

echo "Installazione della stampante"
echo "{Installing printer}"
echo "`n"
Add-Printer -Name "papercut" -DriverName "Kyocera TASKalfa 5054ci KX" -PortName "http://print.dei.unipd.it:631/printers/print"
IF ($?) { 
	echo "Aggiunta la stampante PaperCut"
	echo "{PaperCut printer added}"
	echo "`n"
	Start-Sleep -s 3
	echo "Configurare la stampante seguendo le istruzioni visualizzate a breve"
	echo "IMPORTANTE! Impostare il bianco e nero come scelta predefinita"
	echo "{Set up the printer as showed in the next on-screen instructions}"
	echo "{IMPORTANT! Please set Black and White as the default colour option}"
	echo "`n"
	Start-Sleep -s 5
	Start-Process -filepath ".\Printer-Settings.png"
	Start-Sleep -s 5
	Start-Process -FilePath "C:\Windows\System32\rundll32.exe" -ArgumentList "printui.dll,PrintUIEntry /n `"papercut`" /p"
}	
else{
	echo "Impossibile completare l'installazione della stampante!"
	echo "{Printer installation has failed!}"
}

PAUSE
