Re: script to map network and default printers



I ran the script on my computer, with extra statements to echo the local
printers it found. Although I've never used but one printer with this
computer, there are three printers showing in the Printers applet of Control
Panel. The script found all three configured as local. I imagine you have a
similar situation - at least one printer is shown in Control Panel so the
script does not map any printers.

We need to find another property exposed by the Win32_Printer class that
indicates if the printer is connected. So far I haven't found it.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"rocketz21" <rocketz21@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7B93A0BA-01DF-4B6A-BB2D-8DB1CB76D8CB@xxxxxxxxxxxxxxxx
That was my mistake on the loopback, I was thinking I had to do something
else. I placed the script in the logon under group policy where I mapped
my
network drives.

I don't get an error, but it also doesn't seem to be doing anything. I
run
it manually and it doesn't add any printers and doesn't give me an error
either. Here is the script:

Const LOCAL_PRINTER = 64
Set objNetwork = CreateObject("Wscript.Network")

' Retrieve NetBIOS name of local computer.
strComputer = objNetwork.ComputerName

' Determine if there are any local printers.
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
& strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery("SELECT * FROM Win32_Printer")

blnLocal = False
For Each objPrinter In colPrinters
If (objPrinter.Attributes And LOCAL_PRINTER) <> 0 Then
blnLocal = True
Exit For
End If
Next

If (blnLocal = False) Then
' Map correct printer for each computer.
Select Case LCase(strComputer)
Case "ll_pc31", "ll_pc30"
objNetwork.AddWindowsPrinterConnection "\\smwav\LinoAccounting"
objNetwork.AddWindowsPrinterConnection "\\smwav\HP2100"
objNetwork.SetDefaultPrinter "\\smwav\LinoAccounting"
End Select
End If


Anything else I can try for next week?

"Richard Mueller [MVP]" wrote:

I'm not sure which is line 14, but I see I had a typo. I had
"Win32_Printers" when it should be "Win32_Printer". The statement should
be:

Set colPrinters = objWMIService.ExecQuery("SELECT * FROM Win32_Printer")

I would first test the script by running it manually at a command prompt
while logged in as a normal user. It is much easier to troubleshoot this
way. I'm don't know what a loopback policy is. Are you configuring the
logon
script in a Group Policy for the OU? The Group Policy setting is:

User Configuration, Windows Settings, Scripts (Logon/Logoff), Logon

I right click the VBScript file and select copy, which places a copy of
the
file on the clipboard, then navigate to the Logon setting in the Group
Policy editor, click "Show Files..." and paste the file in the dialog.
This
places the file in the correct location. I hope this helps.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--




.



Relevant Pages

  • Re: Installing patchs and apps automatically
    ... And, Mark, I would completely agree with Mssr. ... script being the 'best' way to add the printers. ... I would consider using a .vbs logon script. ...
    (microsoft.public.win2000.active_directory)
  • Re: Printer Install Automation / Group Policy?
    ... There's no Group Policy setting that will specifically allow you to map a printer, which is to say that there is no setting where you can specify, at an Org or Site level, a UNC path to a network printer that you want everyone to map to. ... You can also place this code in a logon script and it will produce the same effect, and I would actually recommend you do it that way. ... what is the correct way to install printers ...
    (microsoft.public.windows.server.general)
  • Re: Domain Logon Script Advice
    ... users printers and network shares based upon which Active Directory OU ... I happy with deploying the script via GPO etc, ... A very basic VBScript logon script to map the same printer and shares to all ...
    (microsoft.public.scripting.wsh)
  • RE: Conigure Client with Printer and Share Automatically
    ... You can install printers and software to be either machine, ... Is their anything out there which can mimic the SBS Client Deployment on ... 'this script kills all existing network printers ... group policy on W2k3R2 can roll out printers to clients. ...
    (microsoft.public.windows.server.general)
  • Printer question
    ... This question is not as much the content within a script, ... What is the best way to assign default printers with the following conditions. ... Thin clients using Citrix. ... OU and assigning a GPO to the container, however Thin clients are not in ADS. ...
    (microsoft.public.scripting.vbscript)

Loading