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
 
Last edited:
Thanks for looking at it. I really don't do any VBS so I would be wildly guessing.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,623
Latest member
AndersonLo
Back