Re: Printer Logon script with RootDSE, Subnets, Location

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 01/19/05


Date: Wed, 19 Jan 2005 21:45:29 +0100

DJ Burdette wrote:

> I'm trying to make a logon script that will determine the workstations
> Subnets, and Location to determine what printers it should install. I've
> found the information from dsquery subnet -name 192.168.1.*|dsget
> subnet -loc. This way users won't have to go into Start, Search, Printers,
> Printer on the network. I already have the subnets setup on the system, but
> I'm having a hard time getting a script to determine what the location is,
> and then I have to figure out how to tell it to lookup and install all
> printers with this information. Any help would be appreciated.
Hi

If you have Active Directory, and your AD Sites are defined up
along with your subnet locations, this is another way
(using VBScript):

'--------------------8<----------------------
Set oADsSysInfo = CreateObject("ADSystemInfo")
sSiteName = oADsSysInfo.SiteName

' use only lowercase text in the site names tests
Select Case LCase(sSiteName)
   Case "something1"
     MapDrive "k:", "\\server1\share"
   Case "something2"
     MapDrive "k:", "\\server2\share"
   Case "something3"
     MapDrive "k:", "\\server3\share"
End Select

Sub MapDrive(ByVal sDriveLetter, ByVal sUNCPath)
   Set oWshNet = CreateObject("WScript.Network")

   On Error Resume Next
   oWshNet.RemoveNetworkDrive sDriveLetter, True
   On Error Goto 0
   oWshNet.MapNetworkDrive sDriveLetter, sUNCPath

End Sub
'--------------------8<----------------------

WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp

-- 
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx


Relevant Pages

  • Printer Logon script with RootDSE, Subnets, Location
    ... I'm trying to make a logon script that will determine the workstations ... Subnets, and Location to determine what printers it should install. ...
    (microsoft.public.windows.server.scripting)
  • Re: Printer Logon script with RootDSE, Subnets, Location
    ... only have one site and many subnets. ... and Location to determine what printers it should install. ... > oWshNet.RemoveNetworkDrive sDriveLetter, True ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.windows.server.scripting)
  • Re: Create a selection list with VBScript and HTA
    ... > 1) Query AD for the list of printers in the users OU. ... > 3) Install or uninstall the printers as necessary. ... I think I wrote an HTA logon script several years ago at my last job ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.scripting.vbscript)
  • Re: Domain Logon Script Advice
    ... users printers and network shares based upon which Active Directory OU ... scripting for this purpose, only use batch files. ... then use the Parent method to retrieve the parent ... ' Map drives and printers. ...
    (microsoft.public.scripting.wsh)
  • Re: Domain Logon Script Advice
    ... users printers and network shares based upon which Active Directory OU ... scripting for this purpose, only use batch files. ... then use the Parent method to retrieve the parent ... ' Map drives and printers. ...
    (microsoft.public.scripting.wsh)