VBScript to ping printer then send a test page

Hi all

I don't know if this is even possible but will ask anyways.

Does anyone know if it is at all possible to have a list of IP addresses of printers have a script ping the printer and when there is a reply send a test page to a printer ? Or does any one have suggestions on what can be done.
Thanks all
LVL 1
MattywertsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
RobSampsonConnect With a Mentor Commented:
Hi, this VBS code should work for you.

Regards,

Rob.

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
strInputFile = "PrinterIPs.txt"
Set objInput = objFSO.OpenTextFile(strInputFile, ForReading, False)
While Not objInput.AtEndOfStream
	strIPAddress = Trim(objInput.ReadLine)
	If strIPAddress <> "" Then
		If Ping(strIPAddress) = True Then
			strCommand = "RUNDLL32 PRINTUI.DLL,PrintUIEntry /n""" & strIPAddress & """ /k"
			objShell.Run strCommand, 1, True
		Else
			WScript.Echo strIPAddress & " did not respond to ping."
		End If
	End If
Wend
objInput.Close

Function Ping(strComputer)
	Dim objShell, boolCode
	Set objShell = CreateObject("WScript.Shell")
	boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
	If boolCode = 0 Then
		Ping = True
	Else
		Ping = False
	End If
End Function

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
I don't know if all network printers respond to 'ping' but I just checked my HP Laserjet and it does.  There is no requirement for them to do that so you should probably check them individually before relying on that methods.
0
 
MattywertsAuthor Commented:
Thanks Dave, much appreciated. All of our Network printers respond to ping.

Still working on it but I may have to seperate them into two separate scripts. And run them that way.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Dave BaldwinFixer of ProblemsCommented:
Good, now you know part of it will work.  I tend to develop things 1 step at a time myself.  Make it easier to figure things out, at least for me.
0
 
MattywertsAuthor Commented:
Rob,

Thanks, spot on!!! Your help is much appreciated!!!
0
 
RobSampsonCommented:
No problem. Thanks for the grade.

Rob.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.