Solved

VBScript to ping printer then send a test page

Posted on 2012-04-04
6
950 Views
Last Modified: 2012-04-07
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
0
Comment
Question by:Mattywerts
  • 2
  • 2
  • 2
6 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37809709
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
 
LVL 1

Author Comment

by:Mattywerts
ID: 37814481
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 37814662
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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 37815794
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
 
LVL 1

Author Closing Comment

by:Mattywerts
ID: 37817790
Rob,

Thanks, spot on!!! Your help is much appreciated!!!
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 37818805
No problem. Thanks for the grade.

Rob.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question