Computer Start Up Script Drive Mappings

  • Thread starter Thread starter Matt Stassen
  • Start date Start date
M

Matt Stassen

I have a bunch of computers that I need to map a network drive to. I know
that I can do this easily with a user login script but I want to restrict
the drive mappings to certain computers so my students can only access that
drive mapping when they are in that lab.

Thank you for your help
Matt Stassen
Network Administrator
Connally ISD
 
If you enable loopback processing and apply a batch file that maps the
drives to the computer, then that should work. Make sure you use the
/persistent:no switch, otherwise if users have roaming profiles, they'll get
they'll retain the drive mapping.

Of course, this does nothing to prevent users actively browsing for the
share.

Oli
 
'This works well for a small amount of users, AS A LOGIN SCRIPT.

Option Explicit
Dim WshNetwork, WshShell, colDrives, objNetwork, clPrinters
Dim strUserDomain, sComputerName, sUserName, iCount

Set WshNetwork = CreateObject("WScript.Network")
set WshShell = createobject("WScript.Shell")
Set colDrives = WshNetwork.EnumNetworkDrives
Set objNetwork = WScript.CreateObject("WScript.Network")

On Error Resume Next
'Make sure user & computer name is tested in Upper Case
strUserDomain = objNetwork.UserDomain
sComputerName = UCase(WshNetwork.ComputerName)
sUserName = UCase(WshNetwork.Username)



IF strUserDomain = "DEVELOPMENT" Then

'Clear all user mapped drives on shares
For iCount = 0 to colDrives.Count-1 Step 2
WshNetwork.RemoveNetworkDrive colDrives.Item(iCount)
Next

iF sComputerName <> "SERVER" Then

WshNetwork.MapNetworkDrive "H:", "\\assoftsvr\home\"
& sUserName,false
WshShell.Run "net time /rtsdomain:development /set
/yes",0,true
WshShell.Run "net use X: \\assoftsvr\CDRom",0,true
'WshShell.SendKeys "{NUMLOCK}"


Select case sUserName
Case "USER1"
WshNetwork.MapNetworkDrive "L:",
"\\assoftsvr\alltasks",false
WshNetwork.MapNetworkDrive "M:",
"\\assoftsvr\clientscode",false
WshNetwork.MapNetworkDrive "N:",
"\\assoftsvr\personal",false
WshNetwork.MapNetworkDrive "O:",
"\\assoftsvr\documents",false
WshNetwork.MapNetworkDrive "P:",
"\\assoftsvr\applications",false
WshNetwork.AddPrinterConnection "LPT1:",
"\\assoftsvr\LexOptra.0"
WshNetwork.AddPrinterConnection "LPT2:",
"\\assoftsvr\LexOptra.1"
WshNetwork.AddPrinterConnection "LPT3:",
"\\assoftsvr\LexOptra.2"
WshNetwork.SetDefaultPrinter
"\\assoftsvr\LexOptra.0"
WshShell.Run "XCOPY \\assoftsvr\Vet\*.da? c:\vet
/C/D/Q/R/Y",0,true
Case "USER2"
WshNetwork.MapNetworkDrive "L:",
"\\assoftsvr\alltasks",false
WshNetwork.MapNetworkDrive "M:",
"\\assoftsvr\clientscode",false
WshNetwork.MapNetworkDrive "N:",
"\\assoftsvr\personal",false
WshNetwork.MapNetworkDrive "O:",
"\\assoftsvr\documents",false
WshNetwork.MapNetworkDrive "P:",
"\\assoftsvr\applications",false
WshNetwork.AddPrinterConnection "LPT1:",
"\\assoftsvr\LexOptra.0"
WshNetwork.SetDefaultPrinter
"\\assoftsvr\LexOptra.0"
Case "USER3"
WshNetwork.MapNetworkDrive "O:",
"\\assoftsvr\documents",false
WshNetwork.AddPrinterConnection "LPT1:",
"\\assoftsvr\LexOptra.0"
WshNetwork.SetDefaultPrinter
"\\assoftsvr\LexOptra.0"
WshShell.Run "XCOPY \\assoftsvr\Vet\*.da? c:\vet
/C/D/Q/R/Y",0,true
Case "USER4"
WshNetwork.MapNetworkDrive "O:",
"\\assoftsvr\documents",false
WshNetwork.AddPrinterConnection "LPT1:",
"\\assoftsvr\LexOptra.0"
WshNetwork.SetDefaultPrinter
"\\assoftsvr\LexOptra.0"
WshShell.Run "XCOPY \\assoftsvr\Vet\*.da? c:\vet
/C/D/Q/R/Y",0,true
End Select
Elseif WshNetwork.ComputerName = "ASSOFTSVR" Then
WshNetwork.MapNetworkDrive "O:",
"\\assoftsvr\documents",false
End If

'Set fso = CreateObject("Scripting.FileSystemObject")
'Set a = fso.GetFile("\\Assoftsvr\Documents\My
Pictures\wallpaper\" & weekday(date) & ".jpg")
'a.Copy ("c:\files\newtest.jpg")

'Wscript.Echo "System Configuration Complete"
'Wscript.Echo "user: " & sUserName
'Wscript.Echo "Computer: " & sComputerName

End If

Set WshShell = nothing
Set WshNetwork = nothing
Set colDrives = Nothing
Set objNetwork = Nothing
 
Name the computers so that you can identify them with
VBScript such as WSLAB1-009923. Then in your script
check the computer name and if it has LAB1 in it then map
to the resource. If you want to secure the data create a
global group and local group in AD. Add all the computers
that will need to access to the global group (you will
have to change the object types allowed in the group).
Make the global group a member of a local group. Remove
undesired access to the data and add the local group and
assign access that you want to give to the LAB via NTFS.
 
Back
Top