Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript to ping printer then send a test page

Posted on 2012-04-04
6
Medium Priority
?
993 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 84

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 84

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview

876 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