im trying to map some drives, using some error control.i know the script is running as i get the message but nothing is mapping..there's a few extra variables there that aren't being used, i had to cut out other code to try narrow down the problem
Option Explicit
Dim ObjNetwork, objShell, groupListD, ADSPath, userPath, listGroup
Dim strComputer, netPrinter, UNCPath, oWMI, colItems, objItem
WScript.Echo "Welcome to the so and so's Domain"
sub MapDrive(byval driveLetter, byval uncPath)
on error resume next
set objNetwork = createobject("Wscript.Network")
objNetwork.MapNetworkDrive driveLetter, uncPath
if err.number = -2147024811 then '
err.clear
driveletter = getNextDrive
if driveLetter <> "" then
MapDrive driveLetter, uncPath
end if
elseif err.number <> 0 then '
end if
end sub
function getNextDrive
set objFSO = createobject("Scripting.FileSystemObject")
for i = 68 to 88 '** Start at ASCI number 68 (D)
drive = chr(i) & ":"
if not objFSO.DriveExists(drive) then
getNextDrive = drive
exit function
end if
next
end function
Function EnvString(variable)
variable = "%" & variable & "%"
EnvString = objShell.ExpandEnvironmentStrings(variable)
End Function
Function IsMember(groupName)
If IsEmpty(groupListD) then
Set groupListD = CreateObject("Scripting.Dictionary")
groupListD.CompareMode = 1
ADSPath = EnvString("userdomain") & "/" & EnvString("username")
Set userPath = GetObject("WinNT://" & ADSPath & ",user")
For Each listGroup in userPath.Groups
groupListD.Add listGroup.Name, "-"
Next
End if
IsMember = CBool(groupListD.Exists(groupName))
End Function
set objNetwork = WSCript.CreateObject("WScript.Network")
set objShell = WScript.CreateObject( "WScript.Shell")
If isMember("dlTempStaff") Then
MapDrive "H:", "\\WIN-3LRLLX93J1B\TempStaffShare"
Else
End If
If isMember("dlMarketing") Then
MapDrive "H:", "\\WIN-3LRLLX93J1B\MarketingShare"
Else
End If
If isMember("dlSales") Then
MapDrive "H:", "\\\\WIN-3LRLLX93J1B\SalesShare"
Else
End If
If isMember("dlManagers") Then
MapDrive "W:", "\\WIN-3LRLLX93J1B\ManagersShare"
MapDrive "X:", "\\WIN-3LRLLX93J1B\TempStaff"
MapDrive "\\WIN-3LRLLX93J1B\MarketingShare"
MapDrive "Z:", "\\WIN-3LRLLX93J1B\SalesShare"
Else
End If
Option Explicit
Dim ObjNetwork, objShell, groupListD, ADSPath, userPath, listGroup
Dim strComputer, netPrinter, UNCPath, oWMI, colItems, objItem
WScript.Echo "Welcome to the so and so's Domain"
sub MapDrive(byval driveLetter, byval uncPath)
on error resume next
set objNetwork = createobject("Wscript.Network")
objNetwork.MapNetworkDrive driveLetter, uncPath
if err.number = -2147024811 then '
err.clear
driveletter = getNextDrive
if driveLetter <> "" then
MapDrive driveLetter, uncPath
end if
elseif err.number <> 0 then '
end if
end sub
function getNextDrive
set objFSO = createobject("Scripting.FileSystemObject")
for i = 68 to 88 '** Start at ASCI number 68 (D)
drive = chr(i) & ":"
if not objFSO.DriveExists(drive) then
getNextDrive = drive
exit function
end if
next
end function
Function EnvString(variable)
variable = "%" & variable & "%"
EnvString = objShell.ExpandEnvironmentStrings(variable)
End Function
Function IsMember(groupName)
If IsEmpty(groupListD) then
Set groupListD = CreateObject("Scripting.Dictionary")
groupListD.CompareMode = 1
ADSPath = EnvString("userdomain") & "/" & EnvString("username")
Set userPath = GetObject("WinNT://" & ADSPath & ",user")
For Each listGroup in userPath.Groups
groupListD.Add listGroup.Name, "-"
Next
End if
IsMember = CBool(groupListD.Exists(groupName))
End Function
set objNetwork = WSCript.CreateObject("WScript.Network")
set objShell = WScript.CreateObject( "WScript.Shell")
If isMember("dlTempStaff") Then
MapDrive "H:", "\\WIN-3LRLLX93J1B\TempStaffShare"
Else
End If
If isMember("dlMarketing") Then
MapDrive "H:", "\\WIN-3LRLLX93J1B\MarketingShare"
Else
End If
If isMember("dlSales") Then
MapDrive "H:", "\\\\WIN-3LRLLX93J1B\SalesShare"
Else
End If
If isMember("dlManagers") Then
MapDrive "W:", "\\WIN-3LRLLX93J1B\ManagersShare"
MapDrive "X:", "\\WIN-3LRLLX93J1B\TempStaff"
MapDrive "\\WIN-3LRLLX93J1B\MarketingShare"
MapDrive "Z:", "\\WIN-3LRLLX93J1B\SalesShare"
Else
End If