Re: Advice on using Win32_Printer



Yes, that code looks fine.

Sometimes people prefer to limit the WQL Query that they use just down to
the properties that they need to consume.

In your code you have:
>>> objItem.Name & Chr(13) _
>>> & "ServerName: " & objItem.ServerName & Chr(13) _
>>> & "ShareName: " & objItem.ShareName & Chr(13) _
>>> & "Port Name: " & objItem.PortName ' w

So this query would work for you as well.
Select Name, ServerName, ShareName, PortName from Win32_Printer
instead of
select * from win32_printer

--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure


"Joseph" <philippeoget@xxxxxxxxxxx> wrote in message
news:ebYvsVkcFHA.3404@xxxxxxxxxxxxxxxxxxxxxxx
> Thank you very much for the link. Is the code Ok as far as you can tell?
>
> TIA
>
> joseph
> "Scott McNairy (MVP)" <v-scomcn@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:uBPhrydcFHA.3184@xxxxxxxxxxxxxxxxxxxxxxx
>> The error code that you are receiving is a WMI Access Denied error.
>>
>> To perform these operations remotely you need to either be an admin on
>> the remote servers (domain admin or local), see this link here for
>> configuration of WMI for non-admin namespace access.
>> http://www.microsoft.com/technet/scriptcenter/resources/wmifaq.mspx#EGAA
>>
>> --
>> Scott McNairy
>> Microsoft MVP - Windows Server Management Infrastructure
>>
>>
>> "Joseph" <philippeoget@xxxxxxxxxxx> wrote in message
>> news:OCiw6JbcFHA.1504@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hello everyone,
>>>
>>> Could someone tell me if this script would do what I want,
>>> which is to enumarate the printers attached to each Server.
>>>
>>> I get an error, which I think indicates that I do not have admin rights
>>> on these servers.
>>> Is that correct?
>>>
>>> If I know that this script would work, then I can add what I need it to
>>> do (create a web page with some of the results returned),
>>> then ask someone else, in another country, to run it for me.
>>> TIA
>>>
>>> 'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printer.asp
>>> On Error Resume Next
>>>
>>> Dim arrPrSrv(7)
>>> Dim i
>>> 'arrPrSrv(0) = "." '. local computer
>>> arrPrSrv(1) = "PrtSrv1"
>>> arrPrSrv(2) = "PrtSrv2"
>>> arrPrSrv(3) = "PrtSrv3"
>>> arrPrSrv(4) = "PrtSrv4"
>>> arrPrSrv(5) = "PrtSrv5"
>>> arrPrSrv(6) = "PrtSrv6"
>>> arrPrSrv(7) = "PrtSrv7"
>>>
>>> For i = 1 To 7
>>>
>>> strComputer = arrPrSrv(i)
>>> Set objWMIService = GetObject("winmgmts:\\" & strComputer &
>>> "\root\cimv2")
>>> Set colItems = objWMIService.ExecQuery("Select * from
>>> Win32_Printer",,48)
>>>
>>> ' WScript.Echo strComputer
>>> For Each objItem In colItems
>>> WScript.Echo "Name: " & objItem.Name & Chr(13) _
>>> & "ServerName: " & objItem.ServerName & Chr(13) _
>>> & "ShareName: " & objItem.ShareName & Chr(13) _
>>> & "Port Name: " & objItem.PortName ' what I'm after - as this
>>> can be used to work out the htm address:
>>>
>>> ' Note that the 'Web Page Address' as displayed by AD
>>>
>>> ' does not work, http://<IP_Address> does
>>> Next
>>>
>>> Next
>>>
>>> If Err <> 0 Then
>>>
>>> If err.Code = 80041003 Then ' 0x0080041003 = admin rights required
>>> ' MsgBox Err.number & Chr(13) _
>>> ' & err.description
>>> WScript.Echo Err.number & Chr(13) _
>>> & err.description
>>> End If
>>>
>>> End If
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: help with solution to keep 2 servers in sync
    ... > that may be uploaded by users through script, ... > uploaded by admins on the admin server. ... "What are the differences between Unison and rsync?" ...
    (comp.os.linux.networking)
  • Re: Std Users, Update Files?
    ... we're using Server 2003 with XP clients. ... So whilst I would love to have a script to do it for me, I lack the knowledge to run it. ... It's worked because all the users were setup with Admin rights, in an effort to more secure the network I have started to change everyone to standard users. ... My original thought was to use "runas" and run it as admin, but this would have left the admin password in the open to see and as it turns out you can't specify the password anyway unless I use a VB script, which is beyond me. ...
    (microsoft.public.windows.server.general)
  • Re: home folder permissions
    ... When I create the accounts I log onto the server as an admin and edit the ... script to the point at the correct OU and location of the newusers.xls I then ...
    (microsoft.public.windows.server.scripting)
  • help with solution to keep 2 servers in sync
    ... we have 1 webserver for our back end PHP processing ... An admin server that is rsync'd to the production server every 5 min ... may be uploaded by users through script, as well as files uploaded through ...
    (comp.os.linux.networking)
  • help with solution to keep 2 servers in sync
    ... we have 1 webserver for our back end PHP processing ... An admin server that is rsync'd to the production server every 5 min ... may be uploaded by users through script, as well as files uploaded through ...
    (alt.php)

Loading