Re: Check default printer

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Grant (gpsnett_at_hotmail.com)
Date: 02/20/04


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
> --
>
>



Relevant Pages

  • Re: Check default printer
    ... My logon scripts do it all the ... "Grant" wrote in message ... > exit the function before it gets to the end, with VB it is siply 'exit ... > it matches the printer for that site then the script exits without doing ...
    (microsoft.public.windows.server.scripting)
  • Re: How to execute the logon script when the network cable is conn
    ... > and then let the script run the logon script. ... > ' exit after the first event. ... I want to apply your suggestion to a wireless network using 802.1x ...
    (microsoft.public.windows.server.scripting)
  • Re: How to execute the logon script when the network cable is conn
    ... > and then let the script run the logon script. ... > ' exit after the first event. ... I want to apply your suggestion to a wireless network using 802.1x ...
    (microsoft.public.win2000.general)
  • Re: Logon script not working
    ... Sorry I dont understand ... ok try to put the logon script name in the logonscript user ... > ex put for the user Mouse on his tab propertieds the valure of the logon ...
    (microsoft.public.windows.server.scripting)
  • Re: Changing a users password non-interactively?
    ... You need expect and a setpass.expect script which ill add ... exit with a nasty warning. ... # Be careful of the COMMAND and UNDOCMD - they are dependant on your ...
    (comp.unix.aix)