Asignación de unidades de red mediante VBScript

¿Quieres aprender cómo asignar unidades de red de forma rápida y sencilla? ¡Entonces este artículo es para ti! En esta ocasión, te enseñaremos cómo utilizar VBScript, una herramienta poderosa para automatizar tareas en Windows, para asignar unidades de red a tus equipos. ¡No pierdas más tiempo manualmente asignando unidades, sigue leyendo y descubre cómo hacerlo de forma eficiente con VBScript!

Uno de los más comunes secuencias de comandos de inicio de sesión utilizado en un entorno de dominio es uno que asigna unidades de red para el usuario final. Hay algunas maneras en que se puede implementar una solución, como usando la política de grupo (preferido), o para compatibilidad con versiones anteriores para pre-Windows 2000, usando la pestaña Perfil en las propiedades de la cuenta de usuario.

Si se utiliza el método Perfil modificando el atributo del usuario “Script de inicio de sesión”, el script en sí debe almacenarse en el NETLOGON carpeta ubicada en el Controladores de dominio (DC). Simplemente copie el archivo en esa ubicación en uno de los controladores de dominio y el archivo se replicará en los controladores de dominio restantes del dominio.

' Map Network Drives, H:, I:, S:, and U:
' -----------------------------------------------------------------'   

Option Explicit

Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4, bUpdateProfile, bForce
Dim WshNetwork, fs

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set fs = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")

bForce = "True"
bUpdateProfile = "True"

strDriveLetter1 = "H:"
strDriveLetter2 = "I:"
strDriveLetter3 = "S:"
strDriveLetter4 = "U:"

strRemotePath1 = "\\serverName\shareName"
strRemotePath2 = "\\serverName\shareName"
strRemotePath3 = "\\serverName\shareName"
strRemotePath4 = "\\serverName\shareName"

'Section which remove the drives:
If fs.DriveExists(strDriveLetter1) Then WshNetwork.RemoveNetworkDrive strDriveLetter1, bForce, bUpdateProfile End If
If fs.DriveExists(strDriveLetter2) Then WshNetwork.RemoveNetworkDrive strDriveLetter2, bForce, bUpdateProfile End If
If fs.DriveExists(strDriveLetter3) Then WshNetwork.RemoveNetworkDrive strDriveLetter3, bForce, bUpdateProfile End If
If fs.DriveExists(strDriveLetter4) Then WshNetwork.RemoveNetworkDrive strDriveLetter4, bForce, bUpdateProfile End If

'Section which maps drives:
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1, bUpdateProfile
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2, bUpdateProfile
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3, bUpdateProfile
objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4, bUpdateProfile

' Extra code just to add a message box
' WScript.Echo "Map drives " & strDriveLetter1 & strDriveLetter2 & strDriveLetter3 & " & " & strDriveLetter4

Wscript.Quit
'End of Windows Logon Script

🟢 Configurar scripts de LOGON en usuarios de Active Directory en Windows Server ⚡

Puedes utilizar scripts de inicio de sesión para asignar tareas que se realizarán cuando un usuario inicie sesión en un equipo ...

Deja un comentario