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

微软技术 Winter 5年前 (2015-03-10) 3015次浏览 已收录 0个评论

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”


癹冬阁 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:AD域环境下映射网络磁盘VBS脚本
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址