Reply
Old March 27th, 2008 Top | #1
 
j79zlr's Avatar
Glaanies script monkey
Joined: February 2003
Location: Chicago
Posts: 2,725
Reputation: 1520
Power: 155

Default VBS script to check printer status

I got a guy at my forum asking about a VBS to check to see if a printer is on or off. I really have no idea, if someone does could you take a look? http://www.j79zlr.com/phpBB3/viewtopic.php?f=8&t=329
j79zlr is offline   Reply With Quote
Old March 27th, 2008 Top | #2

OSNN Folding Team  
falconguard's Avatar
Carbon based lifeform
Joined: February 2004
Location: SoCal
Posts: 3,406
Reputation: 2305
Power: 158

Default Re: VBS script to check printer status

Could he do an lpstat -p?

falconguard is offline   Reply With Quote
Old March 27th, 2008 Top | #3

OSNN Folding Team  
fitz's Avatar
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,028
Reputation: 2947
Power: 168

Default Re: VBS script to check printer status

i'm still not quite sure what he's trying to do.. his batch file "example" makes no sense..

what is this doing?
Code:
%SystemRoot%\pv.exe > result.txt
and why use a vbscript file to just display a message?
Code:
call You Have Left The Printer On.vbs
What he says and what he is showing seem to be two different things..

Going by what he said, he could create a vbscript file to run as a shutdown script..

The template below will check the status of the printer and display a box with just an OK button telling him to shut off the printer.

If he were to, say, go into his local policies and add the script as a shutdown script, it should run.. not sure if/how the message box will display or not in the middle of a shutdown though.

objPrinter.PrinterStatus=3 is the "ready" printer state
strPrinter should be set to the name of the printer
strComputer really isn't necessary as it is just the local PC.. force of habit for me.
Code:
'run at shutdown to check the status of a printer

Option Explicit
Dim objWMI, objPrinter, colPrinters, strComputer,strPrinter,strWMIQuery

strComputer = "."
strPrinter = "Some Printer Name"
strWMIQuery = "SELECT * FROM Win32_Printer WHERE name=""" & strPrinter & """"

set objWMI = GetObject ("winmgmts:\\" & strComputer & "\root\CIMV2")

set colPrinters = objWMI.ExecQuery(strWMIQuery)

for each objPrinter in colPrinters
    if not(objPrinter.PrinterStatus=3) then
        msgbox "Turn off the Printer!",0,"Printer Is Still On!"
    end if
next

wscript.quit
fitz is offline   Reply With Quote
Old March 28th, 2008 Top | #4
 
j79zlr's Avatar
Glaanies script monkey
Joined: February 2003
Location: Chicago
Posts: 2,725
Reputation: 1520
Power: 155

Default Re: VBS script to check printer status

Thanks for looking at it. I really don't do any VBS so I would be wildly guessing.
j79zlr is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
Online Status Techno Child Site Problems & Feedback 6 June 12th, 2006 12:31am
Status Update Electronic Punk Site Problems & Feedback 57 November 9th, 2003 3:46am
Status Bar i_pedal Windows Desktop Systems 7 July 31st, 2003 2:28pm
I.E status Bar Gone psx2000 Windows Desktop Systems 2 April 9th, 2003 2:31am
status bar in IE npfanz Windows Desktop Systems 3 February 18th, 2002 12:54pm