I have a need to check if the local printer HP LaserJet 4 is already
installed on the local machine and quit if it is. If not the printer should
be installed on the local machine. I am fairly new to scripting and got this
example from another posting from Torgeir and have been trying to modify it
to work for me. I seem to be having a syntax issue in the WshShell.run
statement, but I am unsure how to correct the issue.
Set oPrnSet = GetObject( _
"winmgmts:{impersonationLevel=impersonate}!//localhost") _
.ExecQuery("select Name from Win32_Printer")
Set WshShell = WScript.CreateObject ("WScript.Shell")
For Each oPrn in oPrnSet
If Lcase(oPrn.Name) = LCase("HP LaserJet 4") Then
Wscript.Quit
Else
WshShell.run rundll32 printui.dll,PrintUIEntry /q /if /b "HP LaserJet 4" /f
%windir%\inf\ntprint.inf /r "lpt2:" /m "HP LaserJet 4"
End If
Next
If anyone could provide an explanation of what I'm doing wrong it will be
appreciated!!!
Joel