Necesito ayuda para realizar un script que me permita seleccionar en usuario
que se logonea y que proceda de una determinada manera según quien se
logonee.
Ej:
Si es el usuario "juan" entonces
mapea h: \\servidor\home
mapea x: \\servidor\compras
fin si
Si es el usuario "pedro" entonces
mapea h: \\servidor\home
mapea p: \\servidor\servicios
fin sin
Muchas gracias!
Martín.
There are many ways to map shares based on user names. Here is a batch file
solution. It assumes that user JDoe has a share called \\Server\JDoe and
that user ASmith has a share \\Server\ASmith.
1. In your logon script you insert these lines:
@echo off
net use h: \\Server\home
if exist \\Server\%UserName%\netlogon\netlogon.bat call
\\Server\%UserName%\netlogon\netlogon.bat
2. You create this file, here shown for user JDoe:
\\Server\JDoe\netlogon\netlogon.bat
Inside this file you put the user-specific share commands:
net use P: \\Server\servicios
net use S: \\Server\sales
etc.
3. If you wish then you can hide the folder \\Server\JDoe\netlogon\.
Try this you just need change the StrHData,StrPData,StrXData
varaiables for s vbscript solution
On Error Resume Next
'// Dims Variables
Dim objFSO,objSysInfo
Dim WshNetwork,WshShell
Dim strUserDN,strDrive
'// Sets Stuff
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
set WshNetwork = CreateObject("Wscript.Network")
Set WshShell = CreateObject("WScript.Shell")
strUserDN = WshNetwork.username
strHDrive = "H:"
StrHData = "\\servidor\home"
strXDrive = "X:"
StrXData = "\\servidor\compras"
strPDrive = "P:"
StrPData = "\\servidor\servicios"
'Call debug 'Used to debug user login information
''''''''' Starts Login Script '''''''''
if strUserDN = "juan" then
WshNetwork.RemoveNetworkDrive strHDrive 'Removes H Network Drive
Upon Login
WshNetwork.MapNetworkDrive strHDrive, strHData 'Adds H Network
Drive Upon Login
WshNetwork.RemoveNetworkDrive strXDrive 'Removes X Network Drive
Upon Login
WshNetwork.MapNetworkDrive strXDrive, strXData 'Adds X Network
Drive Upon Login
elseif strUserDN = "pedro" then
WshNetwork.RemoveNetworkDrive strHDrive 'Removes H Network Drive
Upon Login
WshNetwork.MapNetworkDrive strHDrive, strHData 'Adds H Network
Drive Upon Login
WshNetwork.RemoveNetworkDrive strPDrive 'Removes X Network Drive
Upon Login
WshNetwork.MapNetworkDrive strPDrive, strPData 'Adds X Network
Drive Upon Login
end if
Function debug
wscript.echo "Username: " & strUserDN
wscript.echo "UserPath: WinNT://" & strADDN & "/" & strGroupDN
End Function
'// Closes Stuff
Set objFSO = Nothing
Set objSysInfo = Nothing
set WshNetwork = Nothing
Set WshShell = Nothing
You could add your mapping to a dictionary object and then use this to
map your drive. Try the code below as an example:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Explicit
Dim oWNT, oFSO, oDrives, sUsername, sDrive, sPath, sMapping
Set oWNT = CreateObject("WScript.Network")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oDrives = CreateObject("Scripting.Dictionary")
oDrives.CompareMode = 1 'Case insensitive text compare
' Add your users to the dictionary. Separate mappings
' with the pipe (|) symbol
'____________________________________________________________
oDrives("juan") = "H:/Home|X:\\servidor\compras"
oDrives("pedro") = "H:/Home|P:\\servidor\servicios"
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
sUsername = oWNT.Username
For Each sMapping in Split(oDrives(sUsername), "|")
sDrive = Split(sMapping, ":")(0) & ":"
sPath = Split(sMapping, ":")(1)
If LCase(sPath) = "/home" Then sPath = FindHome(sUsername)
If oFSO.DriveExists(sDrive) Then
If oFSO.GetDrive(sDrive).DriveType = 3 Then
oWNT.RemoveNetworkDrive sDrive, True
End If
End If
oWNT.MapNetworkDrive sDrive, sPath, False
Next
Function FindHome(ByVal sUsername)
Dim oWSH, sDomain, oUser
Set oWSH = CreateObject("WScript.Shell")
sDomain = oWSH.Environment("Process").Item("UserDomain")
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUsername)
FindHome = oUser.HomeDirectory
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Martín Companucci" <compa...@gmail.com> escribió en el mensaje de
noticias:64135B8E-4BE3-4A7A...@microsoft.com...