I added the ability to read the printer names and driver names on a remote
machine to an HTA that my desktop team uses. The misreprentation that I
noticed is that the driver name retrieved by the HTA in two particular
examples is Lexmark T634 (with a
single-space in the middle) and the driver that is actually installed is the
Lexmark T634 (with a double-space in the middle).

Has anyone seen this inconsistency or know why it is doing this?

Below is my method from the HTA.

Thanks,

Bart Perrier

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub GetInstalledPrinters
On Error Resume Next
strComputer = GetStrComputer

If Trim(strComputer) <> "" Then
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

If ErrorConnecting(strComputer) = False Then
Set colInstalledPrinters = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer")

For Each objInstalledPrinter in colInstalledPrinters
strHTML = strHTML & "Printer Name -- " & objInstalledPrinter.Name &
"<br>" & _
"Driver Name -- " & objInstalledPrinter.driverName & "<br>"

' this actually does not work remotely
If objInstalledPrinter.Default = "True" Then
strHTML = strHTML & "-- DEFAULT PRINTER --" & "<br>"
End If

strHTML = strHTML & "<br>"
Next
End If
DataArea1.InnerHTML = strHTML
End If
End Sub ' End GetPrinterPorts

Re: Misrepresented values in Win32_Printer by Michael

Michael
Fri May 12 21:52:04 CDT 2006

Bart Perrier wrote:
> I added the ability to read the printer names and driver names on a
> remote machine to an HTA that my desktop team uses. The
> misreprentation that I noticed is that the driver name retrieved by
> the HTA in two particular examples is Lexmark T634 (with a
> single-space in the middle) and the driver that is actually installed
> is the Lexmark T634 (with a double-space in the middle).
>
> Has anyone seen this inconsistency or know why it is doing this?
>


When you build HTML (as strings) to be inserted dynamically as you are
doing, multiple embedded spaces will be normalized to single spaces.
Replaces spaces with &nbsp; using the Replace() function (or RegExp) when
you construct the string of HTML you are inserting.


> Below is my method from the HTA.
>
> Thanks,
>
> Bart Perrier
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Sub GetInstalledPrinters
> On Error Resume Next
> strComputer = GetStrComputer
>
> If Trim(strComputer) <> "" Then
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" & strComputer &
> "\root\cimv2")
>
> If ErrorConnecting(strComputer) = False Then
> Set colInstalledPrinters = objWMIService.ExecQuery _
> ("SELECT * FROM Win32_Printer")
>
> For Each objInstalledPrinter in colInstalledPrinters
> strHTML = strHTML & "Printer Name -- " & objInstalledPrinter.Name
> & "<br>" & _
> "Driver Name -- " & objInstalledPrinter.driverName & "<br>"
>
> ' this actually does not work remotely
> If objInstalledPrinter.Default = "True" Then
> strHTML = strHTML & "-- DEFAULT PRINTER --" & "<br>"
> End If
>
> strHTML = strHTML & "<br>"
> Next
> End If
> DataArea1.InnerHTML = strHTML
> End If
> End Sub ' End GetPrinterPorts

--
Michael Harris
Microsoft MVP Scripting



Re: Misrepresented values in Win32_Printer by Bart

Bart
Mon May 15 10:33:50 CDT 2006

I have noticed that when I was trying to format results.

Thanks for the tip, Michael.

Bart Perrier

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:emLJ$hjdGHA.4108@TK2MSFTNGP03.phx.gbl...
> Bart Perrier wrote:
> > I added the ability to read the printer names and driver names on a
> > remote machine to an HTA that my desktop team uses. The
> > misreprentation that I noticed is that the driver name retrieved by
> > the HTA in two particular examples is Lexmark T634 (with a
> > single-space in the middle) and the driver that is actually installed
> > is the Lexmark T634 (with a double-space in the middle).
> >
> > Has anyone seen this inconsistency or know why it is doing this?
> >
>
>
> When you build HTML (as strings) to be inserted dynamically as you are
> doing, multiple embedded spaces will be normalized to single spaces.
> Replaces spaces with &nbsp; using the Replace() function (or RegExp) when
> you construct the string of HTML you are inserting.
>
>
> > Below is my method from the HTA.
> >
> > Thanks,
> >
> > Bart Perrier
> >
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Sub GetInstalledPrinters
> > On Error Resume Next
> > strComputer = GetStrComputer
> >
> > If Trim(strComputer) <> "" Then
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" & strComputer &
> > "\root\cimv2")
> >
> > If ErrorConnecting(strComputer) = False Then
> > Set colInstalledPrinters = objWMIService.ExecQuery _
> > ("SELECT * FROM Win32_Printer")
> >
> > For Each objInstalledPrinter in colInstalledPrinters
> > strHTML = strHTML & "Printer Name -- " & objInstalledPrinter.Name
> > & "<br>" & _
> > "Driver Name -- " & objInstalledPrinter.driverName & "<br>"
> >
> > ' this actually does not work remotely
> > If objInstalledPrinter.Default = "True" Then
> > strHTML = strHTML & "-- DEFAULT PRINTER --" & "<br>"
> > End If
> >
> > strHTML = strHTML & "<br>"
> > Next
> > End If
> > DataArea1.InnerHTML = strHTML
> > End If
> > End Sub ' End GetPrinterPorts
>
> --
> Michael Harris
> Microsoft MVP Scripting
>
>