В каждой организации пользователи работают с информацией, хранящейся на сетевых ресурсах. Для удобства администраторы настраивают подключение сетевых папок автоматически после захода пользователя в систему. Процедура подключения сетевых папок настраивается с помощью групповых политик.
Чтобы подключить сетевой диск пользователю можно использовать VBS скрипт:
Option Explicit
On Error Resume Next
Dim WshShell, WshNetwork
Set WshShell = WScript.CreateObject("WScript.Shell")
MapDrv "X:", "\\Server_name\Share_name"
Function MapDrv(DrvLet, UNCPath)
Dim WshNetwork ' Object variable
Dim Msg
Set WshNetwork = WScript.CreateObject("WScript.Network")
On Error Resume Next
WshNetwork.RemoveNetworkDrive DrvLet
WshNetwork.MapNetworkDrive DrvLet, UNCPath
Select Case Err.Number
Case 0 ' No error
Case -2147023694
WshNetwork.RemoveNetworkDrive DrvLet
WshNetwork.MapNetworkDrive DrvLet, UNCPath
Case -2147024811
WshNetwork.RemoveNetworkDrive DrvLet
WshNetwork.MapNetworkDrive DrvLet, UNCPath
Case Else
Msg = "Mapping network drive error: " & _
CStr(Err.Number) & " 0x" & Hex(Err.Number) & vbCrLf & _
"Error description: " & Err.Description & vbCrLf
Msg = Msg & "Domain: " & WshNetwork.UserDomain & vbCrLf
Msg = Msg & "Computer Name: " & WshNetwork.ComputerName & vbCrLf
Msg = Msg & "User Name: " & WshNetwork.UserName & vbCrLf & vbCrLf
Msg = Msg & "Device name: " & DrvLet & vbCrLf
Msg = Msg & "Map path: " & UNCPath
WshShell.LogEvent 1, Msg, "SRV"
End Select
End Function
Чтобы подключить сетевой диск пользователю можно использовать VBS скрипт:
Option Explicit
On Error Resume Next
Dim WshShell, WshNetwork
Set WshShell = WScript.CreateObject("WScript.Shell")
MapDrv "X:", "\\Server_name\Share_name"
Function MapDrv(DrvLet, UNCPath)
Dim WshNetwork ' Object variable
Dim Msg
Set WshNetwork = WScript.CreateObject("WScript.Network")
On Error Resume Next
WshNetwork.RemoveNetworkDrive DrvLet
WshNetwork.MapNetworkDrive DrvLet, UNCPath
Select Case Err.Number
Case 0 ' No error
Case -2147023694
WshNetwork.RemoveNetworkDrive DrvLet
WshNetwork.MapNetworkDrive DrvLet, UNCPath
Case -2147024811
WshNetwork.RemoveNetworkDrive DrvLet
WshNetwork.MapNetworkDrive DrvLet, UNCPath
Case Else
Msg = "Mapping network drive error: " & _
CStr(Err.Number) & " 0x" & Hex(Err.Number) & vbCrLf & _
"Error description: " & Err.Description & vbCrLf
Msg = Msg & "Domain: " & WshNetwork.UserDomain & vbCrLf
Msg = Msg & "Computer Name: " & WshNetwork.ComputerName & vbCrLf
Msg = Msg & "User Name: " & WshNetwork.UserName & vbCrLf & vbCrLf
Msg = Msg & "Device name: " & DrvLet & vbCrLf
Msg = Msg & "Map path: " & UNCPath
WshShell.LogEvent 1, Msg, "SRV"
End Select
End Function
Комментариев нет:
Отправить комментарий