Re: Can't setup printer on remote workstation using WMI
- From: "Pete" <xla760@xxxxxxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 13:49:13 +0000 (UTC)
I was having the same problem, so based a script on rundll32 printui.dll
command line as below.
A full list of options is available by entering 'rundll32
printui.dll,PrintUIEntry /?' at cmd prompt.
script ran command below against selected computers, then restarted the
spooler service. This command
will install network printer for all users on a pc.
Set shell = CreateObject("wscript.shell")
shell.run "rundll32 printui.dll,PrintUIEntry /ga /c\\" & strComputer & " /n"
& strPrinter
Pete Forman
"jacksterling84" <jacksterling84@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E63B41C6-A231-46AD-A87C-6D941E2B1947@xxxxxxxxxxxxxxxx
>I have also noticed that the printers do not all list, actually only the
> first printer shows up.
>
> I tried some more experimenting, and this works, but only locally.
> (Remember
> that I need to use my credentials (admin) so that the drivers install
> properly - most of my users don't have admin rights on their
> workstations.)
>
> '---------------------------------------------------------------------------
> wscript.echo vbcrlf & vbcrlf & "**** Using script from :"
> wscript.echo "http://msdn.microsoft.com/library/default.asp?url=" &_
> "/library/en-us/wmisdk/wmi/wmi_tasks__printers_and_printing.asp"
> wscript.echo vbcrlf
> strComputer = "." ' this won't work if you put a remote computer in
> strComputer
> Set objWMIService = GetObject( _
> "winmgmts:{impersonationLevel=Impersonate}!\\" & _
> strComputer & "\root\cimv2")
> Set colPrinters = objWMIService.Get("Win32_Printer")
> Err.clear ' added by me
> errReturn = colPrinters.AddPrinterConnection (strPrinter)
> nLine=100 'added by me (100 is the line where the error will occur)
> wscript.echo vbcrlf & _
> "Error code returned from AddPrinterConnection=" & errReturn
> if Err = 0 then
> wscript.echo vbcrlf & "SUCCESS! - The printer was installed."
> else
> wscript.echo vbcrlf & "Error ( 0x " & hex(err.number) & _
> ") occured on line (" & nLine & ") :" & vbcrlf & _
> err.source & vbcrlf & err.description
> end if
> ' ------------------------------------------------
> And here is output from that section of code:
>
>
> **** Using script from :
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__printers_and_printing.asp
>
> Error code returned from AddPrinterConnection=0
>
> SUCCESS! - The printer was installed.
>
> =========== If I put a remote computer into strComputer ===========
>
> **** Using script from :
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_tasks__printers_and_printing.asp
>
> Error code returned from AddPrinterConnection=
>
> Error ( 0x 8004100C) occured on line (100) :
> SWbemObjectEx
> Not supported
>
.
- Prev by Date: Re: Enumerating Share Permissions with WSH/ADSI/WMI?
- Next by Date: Re: Closing down Windows with a script
- Previous by thread: Re: Enumerating Share Permissions with WSH/ADSI/WMI?
- Next by thread: WMI Execute failure
- Index(es):
Relevant Pages
|