Re: Check default printer
From: Grant (gpsnett_at_hotmail.com)
Date: 02/20/04
- Next message: Michael Harris \(MVP\): "Re: EnumKey fails to enumerate subkeys for long key name"
- Previous message: bbry: "Mapping WIN 98 home dirs"
- In reply to: Richard Mueller [MVP]: "Re: Check default printer"
- Next in thread: Michael Harris \(MVP\): "Re: Check default printer"
- Reply: Michael Harris \(MVP\): "Re: Check default printer"
- Reply: Richard Mueller [MVP]: "Re: Check default printer"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 20 Feb 2004 11:32:07 +1100
Thanks Richard.I was going to put the on error go to but I dont know hot to
exit the function before it gets to the end, with VB it is siply 'exit
function'.
Also this script doesnt tell me what the users default printer is - which I
need to check to avoid setting the printer unecessarily each time at logon.
In other words if they go to the US for a week,and their printer is set at
first logon, subsequent logons should first check the default printer and if
it matches the printer for that site then the script exits without doing
anything.
Cheers,
Grant
"Richard Mueller [MVP]" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in
message news:upQtTX09DHA.1128@tk2msftngp13.phx.gbl...
> Grant:
>
> See my comments below:
>
>
> > Is there a way to check the default printer being used on a system?
> > Our sales guys regularly travel between London, US and Sydney and they
> dont
> > want to remember to change their default printer to the site they are
> logged
> > onto.
> > I'd like to first check that their default printer is not in the site
> being
> > logged into -then set it - My script below simply adds a printer based
on
> > the site being logged into.
> >
> > This is how far Ive got:
> >
> >
> > set objADSysinfo = createobject("ADSystemInfo")
> > Set WshNetwork = CreateObject("WScript.Network")
> >
> > on error resume next
>
> The "On Error Resume Next" statement masks any problems, making
> troubleshooting difficult. I only use it on statements I anticipate might
> raise an error, then I restore normal error handling with "On Error GoTo
0".
> I know it seems unprofessional to let the user see error messages in a
logon
> script, but my philosophy is that if they don't alert me, I'll never know
> something went wrong. At least remove it to troubleshoot.
>
> >
> > If objADSysinfo = "London" then
>
> You need to refer to the SiteName attribute of objADSysinfo. For example,
> use:
>
> If LCase(objADSysinfo.SiteName) = "london" then
>
> I never trust the case returned, so I force either upper or lower when
> testing for values. But, that's probably not necessary in this case.
>
> > WshNetwork.AddWindowsPrinterConnection "server\share"
> > WshNetwork.SetDefaultPrinter "server\share"
> >
> > elseif objADSysinfo = "Washington" then
> > WshNetwork.AddWindowsPrinterConnection "server\share"
> > WshNetwork.SetDefaultPrinter "server\share"
> >
> > elseif objADSysinfo = "Sydney" then
> > WshNetwork.AddWindowsPrinterConnection "server\share"
> > WshNetwork.SetDefaultPrinter "server\share"
> > end if
> >
>
> Otherwise, I think this should work, as long as all clients are at least
> W2k. Oh, except maybe the server names should have "\\" in front.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> HilltopLab web site - http://www.rlmueller.net
> --
>
>
- Next message: Michael Harris \(MVP\): "Re: EnumKey fails to enumerate subkeys for long key name"
- Previous message: bbry: "Mapping WIN 98 home dirs"
- In reply to: Richard Mueller [MVP]: "Re: Check default printer"
- Next in thread: Michael Harris \(MVP\): "Re: Check default printer"
- Reply: Michael Harris \(MVP\): "Re: Check default printer"
- Reply: Richard Mueller [MVP]: "Re: Check default printer"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|