Re: script to map network and default printers
- From: "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 25 May 2007 23:03:52 -0500
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
--
.
- Follow-Ups:
- Re: script to map network and default printers
- From: rocketz21
- Re: script to map network and default printers
- References:
- Re: script to map network and default printers
- From: Richard Mueller [MVP]
- Re: script to map network and default printers
- From: rocketz21
- Re: script to map network and default printers
- From: Richard Mueller [MVP]
- Re: script to map network and default printers
- From: Richard Mueller [MVP]
- Re: script to map network and default printers
- From: rocketz21
- Re: script to map network and default printers
- Prev by Date: Re: GetSpecialFolder(2).ShortPath not always returning fully-shortened path?
- Next by Date: Re: Autorun on USB without autoplay?
- Previous by thread: Re: script to map network and default printers
- Next by thread: Re: script to map network and default printers
- Index(es):
Relevant Pages
|
Loading