Re: Check default printer

From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 02/20/04


Date: Thu, 19 Feb 2004 19:36:07 -0600

Hi,

VBScript also recognizes "Exit Function". It also recognizes "Exit For" (to
exit a "For Each" loop), "Exit Sub", and "Exit Do".

I know of no way to determine the current default printer, except to query
the registry. However, I see no downside to connecting to the printer each
time and re-establishing it as the default. My logon scripts do it all the
time.

-- 
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
"Grant" <gpsnett@hotmail.com> wrote in message
news:%23ogmOw09DHA.2064@TK2MSFTNGP11.phx.gbl...
> 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
    ... 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 ... 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. ...
    (microsoft.public.windows.server.scripting)
  • Re: Users last logon info from logon script
    ... I put this line in the users logon script: ... If I run the script manually, it shows the last logon time. ... I guess it is because Windows update the lastlogon attribute once a user ... Then, for each Domain Controller, ADO is used to search the ...
    (microsoft.public.security)
  • Re: slow logon
    ... in the logon time have been reduced so far. ... update the time for the clients that talk to the dc as the logon server. ... start up script in AD to apply updates to the clients machines which is ...
    (microsoft.public.windows.server.active_directory)
  • Logon Script Causing Laptops To Hang - Problems in script?
    ... I'm using the following script to map drives, ... functions when users logon to our domain. ... 'Disconnects Drives This assures everyone has the same drive mappings. ... objNetwork.MapNetworkDrive strTrainDrv, strPath ...
    (microsoft.public.scripting.vbscript)
  • Re: Disable multiple computers logon
    ... script appended username, computername, date/time, and IP address to a text ... I always cautioned that since the logon scripts ... a malicious user could modify the logs. ...
    (microsoft.public.windows.server.scripting)