Hello everyone,
Newby to VBS sorta...
All I want to do is check to see if a drive exists (already mapped), and if so, remove it... if it doesn't exist, then continue on...
I don't want to remove ALL DRIVES because their HOME DIR is needed...
Here's my code:
============================================
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
If objnetwork.DriveExists("Z:") Then
objnetwork.RemoveNetworkDrive "Z:", True, True
Sleep 300
'then depending on group membership either map drives or printers
Select Case strGroupName
Case "UserGroup1"
objNetwork.AddWindowsPrinterConnection "\\Server\Printer"
objNetwork.RemoveNetworkDrive "Y:", True, True
objNetwork.MapNetworkDrive "Y:", "\\Server\NewShare"
Case "PrinterGroup"
objNetwork.AddWindowsPrinterConnection "\\server\printer"
End Select
set objuser = Nothing
set objnetwork = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
'Quit the Script
wscript.quit
==========================================
Can anyone help me here?
I've checked the FAQs too!!
Brandon
Newby to VBS sorta...
All I want to do is check to see if a drive exists (already mapped), and if so, remove it... if it doesn't exist, then continue on...
I don't want to remove ALL DRIVES because their HOME DIR is needed...
Here's my code:
============================================
On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")
strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)
For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN
If objnetwork.DriveExists("Z:") Then
objnetwork.RemoveNetworkDrive "Z:", True, True
Sleep 300
'then depending on group membership either map drives or printers
Select Case strGroupName
Case "UserGroup1"
objNetwork.AddWindowsPrinterConnection "\\Server\Printer"
objNetwork.RemoveNetworkDrive "Y:", True, True
objNetwork.MapNetworkDrive "Y:", "\\Server\NewShare"
Case "PrinterGroup"
objNetwork.AddWindowsPrinterConnection "\\server\printer"
End Select
set objuser = Nothing
set objnetwork = Nothing
set WSHNetwork = Nothing
set DomainString = Nothing
'Quit the Script
wscript.quit
==========================================
Can anyone help me here?
I've checked the FAQs too!!
Brandon