Skip to content

Instantly share code, notes, and snippets.

@pleonex
Created February 5, 2015 18:50
Show Gist options
  • Save pleonex/68beb0e0f8c06c1f76c6 to your computer and use it in GitHub Desktop.
Save pleonex/68beb0e0f8c06c1f76c6 to your computer and use it in GitHub Desktop.
Reinstall a HP Network Printer
Set objWMIService2 = GetObject("winmgmts:")
Set objNewPort2 = objWMIService2.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort2.Name = "IP_192.168.1.16"
objNewPort2.Protocol = 1
objNewPort2.HostAddress = "192.168.1.16"
objNewPort2.PortNumber = "9100"
objNewPort2.SNMPEnabled = False
objNewPort2.Put_
@echo off
echo Cleaing printer queue. . .
net stop spooler > null
del /F /Q C:\WINDOWS\system32\spool\PRINTERS\*
net start spooler > null
echo Uninstalling printer. . .
printui.exe /dl /n "HP Officejet 6000"
timeout 5 /nobreak > null
echo Installing network printer. . .
cscript C:\Users\MyUser\Desktop\hp.vbs > null
printui /if /b "HP Officejet 6000" /f %windir%\inf\ntprint.inf /r "IP_192.168.1.16" /m "HP Officejet 6000 E609a Series"
timeout 5 /nobreak > null
echo Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment