Re: Check default printer
From: Richard Mueller [MVP] (rlmueller-NOSPAM_at_ameritech.NOSPAM.net)
Date: 02/20/04
- Next message: David H. Lipman: "Re: Problem with get a DHCP Address"
- Previous message: Richard Mueller [MVP]: "Re: Changing User Profile"
- In reply to: Grant: "Re: Check default printer"
- Messages sorted by: [ date ] [ thread ]
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 > > -- > > > > > >
- Next message: David H. Lipman: "Re: Problem with get a DHCP Address"
- Previous message: Richard Mueller [MVP]: "Re: Changing User Profile"
- In reply to: Grant: "Re: Check default printer"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|