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
Who is Participating?

Improve company productivity with a Business Account.Sign Up

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



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
			WScript.Echo strIPAddress & " did not respond to ping."
		End If
	End If

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
		Ping = False
	End If
End Function

Open in new window

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.
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.
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.
MattywertsAuthor Commented:

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

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.