Solved

VBScript to ping printer then send a test page

Posted on 2012-04-04
6
967 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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 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

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.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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