thelke
MIS
- Apr 9, 2002
- 84
I need some help with mapping Shares and Printers based on NT4 Domain Groups.
I have Win2k Clients, and would like to consoldate my login scripts to 1, where I can map shares and printers based on domain groups. I have the mapping of shares down, but cannot get it to base them on groups, and I cannot get the mapping of the printers down at all. I attempted to re-write what I used for mapping shares, and use it for printers, but to no avail.
Any help would be great!
Here is some sample code of what I tried...
dim OlyNet
dim OlyPrinter
dim OlyFSO
dim OlyShell
dim OlyDrives
dim i
dim cmd
on error resume next
set OlyNet = WScript.CreateObject("WScript.Network"
set OlyPrinters = WScript.CreateObject("WScript.Shell"
Set OlyFSO = WScript.CreateObject("Scripting.FileSystemObject"
set OlyShell = CreateObject("WScript.Shell"
set OlyDrives = OlyNet.EnumNetworkDrives
'----- Set Drive Mappings (This clears any existing mappings)
DriveMapping "I:", ""
DriveMapping "J:", ""
DriveMapping "K:", ""
DriveMapping "L:", ""
DriveMapping "M:", ""
DriveMapping "N:", ""
DriveMapping "O:", ""
DriveMapping "P:", ""
DriveMapping "Q:", ""
DriveMapping "R:", ""
DriveMapping "S:", ""
DriveMapping "T:", ""
DriveMapping "U:", ""
DriveMapping "V:", ""
DriveMapping "W:", ""
DriveMapping "X:", ""
DriveMapping "Y:", ""
DriveMapping "Z:", ""
If INGROUP("<Domain>\Accounting"Then
DriveMapping "<Drive>", "<Share>"
End If
If INGROUP("<Domain>\Domain Sales"Then
DriveMapping "<Drive>", "<Share>"
End If
Sub DriveMapping(Drive, Share)
For i = 0 to OlyDrives.Count -1 Step 2
if LCase(Drive) = LCase(OlyDrives.Item(i)) then
if not LCase(Share) = LCase(OlyDrives.Item(i+1)) then
OlyNet.RemoveNetworkDrive Drive, true, true
Else
Exit Sub
End if
End if
Next
OlyNet.MapNetworkDrive Drive, Share
End Sub
'-----Set Printer Mappings
If INGROUP("<Domain>\Accounting"Then
PrinterMapping "<Share>"
End If
If INGROUP("<Domain>\Sales"Then
PrinterMapping "<Share>"
End If
Sub PrinterMapping(Share)
For i = 0 to OlyPrinter.Count -1 Step 2
if LCase(Share) = LCase(OlyPrinter.Item(i+1)) then
Exit Sub
End if
Next
OlyPrinter.Run Share
End Sub
I have Win2k Clients, and would like to consoldate my login scripts to 1, where I can map shares and printers based on domain groups. I have the mapping of shares down, but cannot get it to base them on groups, and I cannot get the mapping of the printers down at all. I attempted to re-write what I used for mapping shares, and use it for printers, but to no avail.
Any help would be great!
Here is some sample code of what I tried...
dim OlyNet
dim OlyPrinter
dim OlyFSO
dim OlyShell
dim OlyDrives
dim i
dim cmd
on error resume next
set OlyNet = WScript.CreateObject("WScript.Network"
set OlyPrinters = WScript.CreateObject("WScript.Shell"
Set OlyFSO = WScript.CreateObject("Scripting.FileSystemObject"
set OlyShell = CreateObject("WScript.Shell"
set OlyDrives = OlyNet.EnumNetworkDrives
'----- Set Drive Mappings (This clears any existing mappings)
DriveMapping "I:", ""
DriveMapping "J:", ""
DriveMapping "K:", ""
DriveMapping "L:", ""
DriveMapping "M:", ""
DriveMapping "N:", ""
DriveMapping "O:", ""
DriveMapping "P:", ""
DriveMapping "Q:", ""
DriveMapping "R:", ""
DriveMapping "S:", ""
DriveMapping "T:", ""
DriveMapping "U:", ""
DriveMapping "V:", ""
DriveMapping "W:", ""
DriveMapping "X:", ""
DriveMapping "Y:", ""
DriveMapping "Z:", ""
If INGROUP("<Domain>\Accounting"Then
DriveMapping "<Drive>", "<Share>"
End If
If INGROUP("<Domain>\Domain Sales"Then
DriveMapping "<Drive>", "<Share>"
End If
Sub DriveMapping(Drive, Share)
For i = 0 to OlyDrives.Count -1 Step 2
if LCase(Drive) = LCase(OlyDrives.Item(i)) then
if not LCase(Share) = LCase(OlyDrives.Item(i+1)) then
OlyNet.RemoveNetworkDrive Drive, true, true
Else
Exit Sub
End if
End if
Next
OlyNet.MapNetworkDrive Drive, Share
End Sub
'-----Set Printer Mappings
If INGROUP("<Domain>\Accounting"Then
PrinterMapping "<Share>"
End If
If INGROUP("<Domain>\Sales"Then
PrinterMapping "<Share>"
End If
Sub PrinterMapping(Share)
For i = 0 to OlyPrinter.Count -1 Step 2
if LCase(Share) = LCase(OlyPrinter.Item(i+1)) then
Exit Sub
End if
Next
OlyPrinter.Run Share
End Sub