jskfan
asked on
Explain the script
can someone comments this script for me. line by line.?
I appreciate it.
On Error Resume Next
Dim GroupList
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Set WshShell = CreateObject("WScript.Shel l")
Set WshNetwork = WScript.CreateObject("WScr ipt.Networ k")
GetGroupInfo()
LogonPath = fso.GetParentFolderName(WS cript.Scri ptFullName )
'************************* ********** ***Group Mappings Based on Grouplist.csv************* ********** **********
If fso.FileExists(logonpath&" \Grouplist .csv") Then
Set grplist = Fso.OpenTextFile(logonpath &"\Groupli st.csv")
' make File into an Array
aGroup = Split(grplist.Readall,vbcr lf)
For I = 0 to UBound(GroupList) ' Check Every Group Membership the user is in (populated into Grouplist)
grpname = Grouplist(i)
For x = 0 to UBound(aGroup) ' Read the entire CSV to make sure all drives are mapped for each Group
mapline = agroup(x)
If InStr(LCase(mapline),LCase (grpname)) Then ' If you're in the group
mapline = Mid(mapline,InStr(mapline, ",")+1) ' Remove the GroupName from the line
Drive = Left(mapline,InStr(mapline ,",")-1) ' Extract Drive Letter
Path = Mid(mapline,InStr(mapline, ",")+1) ' Extract the path
If (fso.DriveExists(drive) <> True) and (Drive<>"!!") Then ' If The Drive is not already mapped
WshNetwork.MapNetworkDrive drive,path,true ' Map The Drive
wscript.sleep 1000
End If
If Drive = "!!" then
WSHNetwork.AddWindowsPrint erConnecti on Path
wscript.sleep 1000
end if
End If
Next
Next
End If
Sub GetGroupInfo
Set UserObj = GetObject("WinNT://" & wshNetwork.UserDomain & "/" & WshNetwork.UserName)
Set Groups = UserObj.groups
For Each Group In Groups
GroupCount = GroupCount + 1
Next
ReDim GroupList(GroupCount -1)
i = 0
For Each Group In Groups
GroupList(i) = Group.Name
i = i + 1
Next
End Sub
I appreciate it.
On Error Resume Next
Dim GroupList
Set fso = CreateObject("Scripting.Fi
Set WshShell = CreateObject("WScript.Shel
Set WshNetwork = WScript.CreateObject("WScr
GetGroupInfo()
LogonPath = fso.GetParentFolderName(WS
'*************************
If fso.FileExists(logonpath&"
Set grplist = Fso.OpenTextFile(logonpath
' make File into an Array
aGroup = Split(grplist.Readall,vbcr
For I = 0 to UBound(GroupList) ' Check Every Group Membership the user is in (populated into Grouplist)
grpname = Grouplist(i)
For x = 0 to UBound(aGroup) ' Read the entire CSV to make sure all drives are mapped for each Group
mapline = agroup(x)
If InStr(LCase(mapline),LCase
mapline = Mid(mapline,InStr(mapline,
Drive = Left(mapline,InStr(mapline
Path = Mid(mapline,InStr(mapline,
If (fso.DriveExists(drive) <> True) and (Drive<>"!!") Then ' If The Drive is not already mapped
WshNetwork.MapNetworkDrive
wscript.sleep 1000
End If
If Drive = "!!" then
WSHNetwork.AddWindowsPrint
wscript.sleep 1000
end if
End If
Next
Next
End If
Sub GetGroupInfo
Set UserObj = GetObject("WinNT://" & wshNetwork.UserDomain & "/" & WshNetwork.UserName)
Set Groups = UserObj.groups
For Each Group In Groups
GroupCount = GroupCount + 1
Next
ReDim GroupList(GroupCount -1)
i = 0
For Each Group In Groups
GroupList(i) = Group.Name
i = i + 1
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.