AD域环境下映射网络磁盘VBS脚本

5,832次阅读
没有评论

AD 域环境下映射网络磁盘 VBS 脚本

On Error Resume Next

Dim objSysInfo

Dim objNetwork

Dim ObjFSO

Dim oShell

WScript.Sleep 5000

Set objSysInfo = Wscript.CreateObject(“ADSystemInfo”)

Set objNetwork = Wscript.CreateObject(“Wscript.Network”)

Set oShell = Wscript.CreateObject(“Shell.Application”)

Set ObjFSO = Wscript.CreateObject(“Scripting.FileSystemObject”)

strUserPath = “LDAP://” & objSysInfo.UserName

Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf

strGroupPath = “LDAP://” & strGroup

Set objGroup = GetObject(strGroupPath)

strGroupName = objGroup.CN

Select Case strGroupName

    ‘ 判断用户所属组

    Case “FIN_ALL”

        ‘ 判断盘符是否存在,若存在则断开

        If(ObjFSO.DriveExists(“S:”))then

            objNetwork.RemoveNetworkDrive”S:”,true

        End If

    WScript.Sleep 1000

        ‘ 添加网络磁盘

        objNetwork.MapNetworkDrive “S:”, “contosofsdepartmentfin”

    WScript.Sleep 1000

        ‘ 更名网络磁盘

        oShell.NameSpace(“S:”).Self.Name = “Department”

    Case “GM_ALL”

        If(ObjFSO.DriveExists(“S:”))then

            objNetwork.RemoveNetworkDrive”S:”,true

        End If

    WScript.Sleep 1000

        objNetwork.MapNetworkDrive “S:”, “contosofsdepartmentceo”

    WScript.Sleep 1000

        oShell.NameSpace(“S:”).Self.Name = “Department”

    Case “IT_ALL”

        If(ObjFSO.DriveExists(“S:”))then

            objNetwork.RemoveNetworkDrive”S:”,true

        End If

    WScript.Sleep 1000

        objNetwork.MapNetworkDrive “S:”, “contosofsdepartmentIS&T”

    WScript.Sleep 1000

        oShell.NameSpace(“S:”).Self.Name = “Department”

End Select

‘ 添加通用磁盘

Next

    ‘ 判断盘符是否存在,若存在则断开

    If(ObjFSO.DriveExists(“X:”))then

        objNetwork.RemoveNetworkDrive”X:”,true

    End If

    WScript.Sleep 1000

        objNetwork.MapNetworkDrive “X:”, “contosofstransfer”

    WScript.Sleep 1000

        oShell.NameSpace(“X:”).Self.Name = “Transfer”

Winter
版权声明:本站原创文章,由 Winter 2015-03-11发表,共计1673字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码
载入中...