VBS script to check printer status

fitz

Woah.. I'm still here?
Political Access
Joined
26 Apr 2004
Messages
4,084
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:

j79zlr

Glaanies script monkey
Political Access
Joined
16 Feb 2003
Messages
2,725
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

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.
Terrahertz wrote on Electronic Punk's profile.
Yo fellas!
Electronic Punk wrote on Sazar's profile.
Where are you buddy?
Perris Calderon wrote on Electronic Punk's profile.
Hey EP! All good with me, applying for Microsoft MVP right now, should have done this a while ago.

Notifications don't work, I only found your response by coming back to hunt up some threads, if you want, give me your email address so we can keep in touch easier!
Perris Calderon wrote on Electronic Punk's profile.
EP, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there!

Forum statistics

Threads
61,997
Messages
673,411
Members
5,590
Latest member
AntonioPR