wmi - long story but exasperated user

A

Alan Gillott

I am struggling to get Windows Instrumentation to work with printers using
either vbScript or dotnet. However the problem I am trying to resolve is not
straight forward. It involves multiple hardware (suppliers) for a printer,
NAS device, (I stupidly bought two) and a Wireless Router and lots of
emotion: wife who expects everything to work, evil stepdaughter and IT dude
husband who designs and builds software and who usually waves these issues
off to IT support - except I am the IT support dude and I am dying in an
emotional morass.

Setup.

Several Laptops, wireless links to an ADSL Linksys (which has its own
issues), ethernet connection to a Maxtor NAS device which in turn drives a
USB Laser Printer (Brother).

In my innocence I saw this as a way to share the houshold printers. Alas &
alak, it doesn't support bi-directional printers so no pretty color printers
& scanners. Grrr.

Issues:

1) I haven't yet been able to set up the maxtor in such a way as it doesn't
require a Logon! Even to use the "public" storage and of course the Printer.

Family objects violently to having to relogon to the maxtor to do printing.
Trying to use the disk is fine, you get a nice dialog automatically,
printing doesn't.

I have a script that does the Logon at startup, except startup doesn't run
when you reactivate Windows after Hibernation and I haven't yet persuaded
the appallingly badly designed Microsoft policy system to do this either.

2) Recycling the Linksys causes the Printer to go, and stay, unReady.

For those who like a good story, or may have an insight, here's why: for
those who are bored, move on...

The Linksys appears to have two problems. a) It shows all the symptoms of
buffer indigestion if at least one device isn't attached via Ethernet and
isn't constantly monitoring the ADSL status. Even if it is, I sometimes have
to go and play hit the refresh button to persuade it to wake up. I have
several emotional scars from this behavior. I think this might also
sometimes be British Telecom's fault for overloading the ADSL circuits but I
can't prove it.

This occurs 3 times or more a day without the Linksys monitor running, about
every other day when it's running.

b) the other issue is more vexing: it appears to convert all the wireless
connections into Ethernet connections, sit up, wag it's tail expect me to
pat it on the head. Changing firmware only changes the frequency of these
behaviors. This can only be resolved by recycling the device and the family
are only too happy to do so.

However thay never remember to recycle the printer (has to be done once
linksys is fully functional again). I get the blame.

I am, apparantly, not important enough to Brother, Maxtor or Cisco to get
any useful assistance...

What i have done so far:

1) I have a vbScript I use to relogon the Maxtor at Boot time. I haven't
persuaded it to run after hibernation though (but see below)

2) I have a VB.NET program, not used in anger though, that can detect
hibernation. This checks the state of the Maxtor and logs everyone on as
needed. Works a dream BUT

I cannot get my head around Woindows Instrumentation and figure out the text
string I need to check it's status (my printers and faxes folder can).
Neither in vbScript nor VB.Net.

The Maxtor is an embedded NT, appears as a node on my peer to peer network
but the Printer is not "owned" by the Maxtor but is a wierd type of USB
device that doesn't have a USB hub as seen by each Laptop (I think that's
why I have to recycle it) The Laptop clients detect it's loss but not it's
reappearance. I want at least to be able to flash lights on Laptops that
can't see it properly - my family might just be motivated to recycle it
before printing 100 page thesises which vanish into some printing black
hole.

Ultimately I want to take metaphorical mallet and wrench to reset it from
each laptop.

Sorry about the length, someone might get a good laugh.

Help!

1) anyone have any idea what magic string I need to give to instrumentation
to check the Printer's status? All the books give lots of examples of
everything but printers.

2) If anyone has insights into the rest of this sorry mess I will fall on
their necks with embarrassing hugs and kisses.

Thanks
 
J

James Garringer

Alan said:
I am struggling to get Windows Instrumentation to work with printers using
either vbScript or dotnet. However the problem I am trying to resolve is not
straight forward. It involves multiple hardware (suppliers) for a printer,
NAS device, (I stupidly bought two) and a Wireless Router and lots of
emotion: wife who expects everything to work, evil stepdaughter and IT dude
husband who designs and builds software and who usually waves these issues
off to IT support - except I am the IT support dude and I am dying in an
emotional morass.

Setup.

Several Laptops, wireless links to an ADSL Linksys (which has its own
issues), ethernet connection to a Maxtor NAS device which in turn drives a
USB Laser Printer (Brother).

In my innocence I saw this as a way to share the houshold printers. Alas &
alak, it doesn't support bi-directional printers so no pretty color printers
& scanners. Grrr.

If you cannot get an elegant solution to your problem have you
considered configuring the printer on one of the computers at your
house and sharing it from that computer? Of course that computer would
need to be turned on to act as the print server.

2) I have a VB.NET program, not used in anger though, that can detect
hibernation. This checks the state of the Maxtor and logs everyone on as
needed. Works a dream BUT

I cannot get my head around Woindows Instrumentation and figure out the text
string I need to check it's status (my printers and faxes folder can).
Neither in vbScript nor VB.Net.

The Maxtor is an embedded NT, appears as a node on my peer to peer network
but the Printer is not "owned" by the Maxtor but is a wierd type of USB
device that doesn't have a USB hub as seen by each Laptop (I think that's
why I have to recycle it) The Laptop clients detect it's loss but not it's
reappearance. I want at least to be able to flash lights on Laptops that
can't see it properly - my family might just be motivated to recycle it
before printing 100 page thesises which vanish into some printing black
hole.

1) anyone have any idea what magic string I need to give to instrumentation
to check the Printer's status? All the books give lots of examples of
everything but printers.

Alan,
Please see my comment about printer sharing above. There are two
properties of the Win32_Printer class that may help you. You can read
more about the Win32_Printer class here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_start_page.asp

On that page open the WMI Reference > WMI Classes > Win32 Classes >
Computer System > Win32_Printer

Another good way to learn about the various WMI Classes and properties
that you can read from devices you can use the Scripting Guys'
Scriptomatic utility available here:

http://www.microsoft.com/downloads/...42-648B-4119-B7EB-783B0F7D1178&displaylang=en


Here are two functions that return the status of a printer. The second
function will not work on Windows 2000 or NT, but the first one will.
The first parameter for each function is the computer name you are
querying, and the second is the device ID of your printer as a string.
Note that this is the name your printer driver gives the printer, not
the printer share name.
-------------------------
MsgBox GetPrinterStatus (".","YourPrinter")

Function GetPrinterStatus(strComputer, strPrinterDevID)
'Accepts a computer name and printer device ID as string parameters
'Returns the printer status as a string
Dim intStatus: intStatus = 0
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
On Error Resume Next
Err.Clear
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer
Where DeviceID = '" _
& strPrinterDevID & "'", "WQL", wbemFlagReturnImmediately + _
wbemFlagForwardOnly)
If Err.Number = 0 Then
For Each objItem In colItems
intStatus = objItem.PrinterStatus
Next
Else
GetPrinterStatus = "Error Getting Printer Status"
End If
Select Case intStatus
Case 1
GetPrinterStatus = "Other"
Case 2
GetPrinterStatus = "Unknown"
Case 3
GetPrinterStatus = "Idle"
Case 4
GetPrinterStatus = "Printing"
Case 5
GetPrinterStatus = "Warmup"
Case 6
GetPrinterStatus = "Stopped Printing"
Case 7
GetPrinterStatus = "Offline"
Case 0
GetPrinterStatus = "Error Getting Printer Status"
End Select
End Function

MsgBox GetExtendedPrinterStatus(".","YourPrinter")

Function GetExtendedPrinterStatus(strComputer, strPrinterDevID)
'Accepts a computer name and printer device ID as string parameters
'Returns the extended printer status as a string
'This function is not supported on Windows 2000 & NT
Dim intStatus: intStatus = 0
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
On Error Resume Next
Err.Clear
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Printer
Where DeviceID = '" _
& strPrinterDevID & "'", "WQL", wbemFlagReturnImmediately + _
wbemFlagForwardOnly)
If Err.Number = 0 Then
For Each objItem In colItems
intStatus = objItem.ExtendedPrinterStatus
Next
Else
GetExtendedPrinterStatus = "Error Getting Printer Status"
End If
Select Case intStatus
Case 1
GetExtendedPrinterStatus = "Other"
Case 2
GetExtendedPrinterStatus = "Unknown"
Case 3
GetExtendedPrinterStatus = "Idle"
Case 4
GetExtendedPrinterStatus = "Printing"
Case 5
GetExtendedPrinterStatus = "Warmup"
Case 6
GetExtendedPrinterStatus = "Stopped Printing"
Case 7
GetExtendedPrinterStatus = "Offline"
Case 8
GetExtendedPrinterStatus = "Paused"
Case 9
GetExtendedPrinterStatus = "Error"
Case 10
GetExtendedPrinterStatus = "Busy"
Case 11
GetExtendedPrinterStatus = "Not Available"
Case 12
GetExtendedPrinterStatus = "Waiting"
Case 13
GetExtendedPrinterStatus = "Processing"
Case 14
GetExtendedPrinterStatus = "Initialization"
Case 15
GetExtendedPrinterStatus = "Power Save"
Case 16
GetExtendedPrinterStatus = "Pending Deletion"
Case 17
GetExtendedPrinterStatus = "I/O Active"
Case 18
GetExtendedPrinterStatus = "Manual Feed"
Case 0
GetExtendedPrinterStatus = "Error Getting Printer Status"
End Select
End Function
 
T

TDM

The Linksys appears to have two problems. a) It shows all the symptoms of
buffer indigestion if at least one device isn't attached via Ethernet and
isn't constantly monitoring the ADSL status. Even if it is, I sometimes
have to go and play hit the refresh button to persuade it to wake up. I
have several emotional scars from this behavior. I think this might also
sometimes be British Telecom's fault for overloading the ADSL circuits but
I can't prove it.

This occurs 3 times or more a day without the Linksys monitor running,
about every other day when it's running.

b) the other issue is more vexing: it appears to convert all the wireless
connections into Ethernet connections, sit up, wag it's tail expect me to
pat it on the head. Changing firmware only changes the frequency of these
behaviors. This can only be resolved by recycling the device and the
family are only too happy to do so.
<snip>

Alan,

You mention a firmware change ?, have you tried non linksys firmware such
as that from openwrt.org ? The firmware here is "supposed" to be much more
reliable then the "stock" firmware. I have used it on the WRT54GL and it
seems
to be very robust. Maybe worth a try.

Sorry, dont have any better answer on printer status then you have already
gotten.
If you are up to spending a bit of change, you could get a USB/Ethernet
adapter
to run the Printer from.

http://www.usbgear.com/USB-Printer-Adapters.html


Good luck.

TDM
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top