Let me start by saying "i'm not a coder"
ok now that that is said....
I found this script on the net and am trying to get it to work for me
(if you have another script that will do the same please advise me.)
I can not get the below to work with the groups I have in AD
Here is the section that is not working properly
i have changed the code to match my enviroment with no success
I get an error : error:local device name is already in use
Could you help me with this section of it
I would greatly appreciate it!
ok now that that is said....
I found this script on the net and am trying to get it to work for me
(if you have another script that will do the same please advise me.)
I can not get the below to work with the groups I have in AD
Code:
- Start Code-
' ********************************************************************************
' *
' * Drive Mapping Script
' * VBScript Version by Bruce Szabo
' * Modified by Bruce Szabo for NACS
' * November 10, 2000
' *
Dim strComputerName
Dim strUserName
Dim strDomainName
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
do while wshNetwork.username = ""
WScript.Sleep 250
loop
strComputerName = wshNetwork.computerName
strUserName = wshNetwork.userName
strDomainName = wshNetwork.userDomain
call subDriveMap
' ********************************************************************************
' *
' * Group Information
' *
Sub subDriveMap()
Dim colNetDrives
Dim strLocal
Dim strRemote
Dim strLocalSets
Dim bForce
Dim bUpdateProfile
bForce = true
bUpdateProfile = true
' Set a variable for a script file to map user specific drives.
strLocalSets = "J:\local.vbs"
' Query the ADSI object to get User Information. Set up the home drive variables.
adspath = "WinNT://" & strDomainName & "/" & strUserName
set adsobj = getobject( adspath )
strHomeDrive = adsobj.homeDirDrive
strHomeDir = adsobj.homeDirectory
' Setup objects to map network drives.
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
Set wshShell = WScript.CreateObject("WScript.Shell" )
Set colNetDrives = wshNetwork.EnumNetworkDrives
' Remove any drive mappings. This removes all drive mappings that might be set using
' reconnect at logon.
If colNetDrives.Count = 0 then
' MsgBox "There are no drive mappings at this time."
Else
For x = 0 to colNetDrives.count-1 Step 2
wshNetwork.RemoveNetworkDrive colNetDrives.Item(x), bForce, bUpdateProfile
Next
End If
' Map Users Home Drive
wshNetwork.MapNetworkDrive strHomeDrive, strHomeDir
' Map Any Global Drives
wshNetwork.MapNetworkDrive "n:", "\\myServerName\myShare"
' Map all Group Specific Drives
for each prop in adsobj.groups
select case UCASE(prop.name)
case "myDomainGlobalGroup1"
wshNetwork.MapNetworkDrive "G:", "\\myServerName\dept1"
case "myDomainGlobalGroup2"
wshNetwork.MapNetworkDrive "G:", "\\myServerName\dept2"
case else
wshNetwork.MapNetworkDrive "G:", "\\myServerName\otherDepts"
end select
next
' Check to see if a User Script Exists and run it.
Set fso = CreateObject("Scripting.FileSystemObject")
IF fso.FileExists(strLocalSets) then
' MsgBox "Local Settings File on the User's Home Drive"
WshShell.Run strLocalSets, 2, TRUE
End If
' *
' * This routine when uncommented will display the mapped drives
' *
Set colNetDrives = wshNetwork.EnumNetworkDrives
Wscript.Echo colNetDrives.Count
If colNetDrives.Count = 0 then
msgBox "There are no drive mappings at this time."
Else
For x = 0 to colNetDrives.count-1 Step 2
strMsg = strMsg & colNetDrives.Item(x) & chr(9) & colNetDrives.Item(x+1) & vbCRLF
Next
msgBox strMsg
End If
End Sub
i have changed the code to match my enviroment with no success
I get an error : error:local device name is already in use
Code:
' Map all Group Specific Drives
for each prop in adsobj.groups
select case UCASE(prop.name)
case "myDomainGlobalGroup1"
wshNetwork.MapNetworkDrive "G:", "\\myServerName\dept1"
case "myDomainGlobalGroup2"
wshNetwork.MapNetworkDrive "G:", "\\myServerName\dept2"
case else
wshNetwork.MapNetworkDrive "G:", "\\myServerName\otherDepts"
end select
next
I would greatly appreciate it!