none
Alguien me puede ayudar con este scrip? RRS feed

  • Pregunta

  • Hola a todos, acabo de crear un scrip para mapear las unidades de red y que le de un mensaje de bienvenida configurando la hora y con privilegios para grupos, el tema es que quiero que el usuario cuando se loguea mapee la unidad personal, unidad de archivos, unidad de servidor de instalaciónes. En unidad personal lo que quiero es que busque el nombre relacionado con el usuario. Ej: G:\dmancini. yo les paso el ejemplo de mi scrip, me crea todo menos esa parte en que me estoy equivocando?. Muchas gracias  y espero que puedan ayudarme.

    Slds.

    Dim WshFS
    Dim WshShell
    Dim WSHNetwork
    Dim UserObj
    Dim UserGroups
    Dim GroupObj
    Dim LastDrive

    ' start of code
    Set WshFS = WScript.CreateObject("Scripting.FileSystemObject")
    Set WSHNetwork = WScript.CreateObject("WScript.Network")
    Set WshShell = WScript.CreateObject("WScript.Shell")

    'Pause Script until User is completely Logged in
    On Error Resume Next
    Username = ""
    Do
       Username = WSHNetwork.UserName
    Loop Until Username <> ""

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Init Variables
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Do
         strUserID = WSHNetwork.UserName
    Loop Until strUserID <> ""

    DomainName = WSHNetwork.UserDomain   ' <RMC1 04/28/04>

    'Get User Object from Domain
    Set UserObj = GetObject("WinNT://" & DomainName & "/" & strUserID)

    'Init Groups
    UserGroups=""
    For Each GroupObj In UserObj.Groups
         UserGroups=UserGroups & "[" & GroupObj.Name & "]"
    Next

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' get local path of Desktop and Programs
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    DesktopPath = WSHShell.SpecialFolders("Desktop")
    ProgramsPath = WSHShell.SpecialFolders("Programs")

    LastDrive = 90  ' start with value of asci upper case Z

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' perform configuration settings
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ConfigurePC  'calls function to perform the actual work

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    '  clean up resources
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    set wsShell = nothing               ' <RMC3 04/28/04>
    set WSHNetwork = Nothing            ' <RMC3 04/28/04>
    set WshFS = nothing                 ' <RMC3 04/28/04>

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'End Script
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Wscript.quit


    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Declare functions
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'Setup Drives / Icons
    '
    '  This is where the administrator would make drive mapping
    '  Evironment variables and search path settings
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub ConfigurePC
        MapDrive "G:", "\\Mi servidor\username"
        MapDrive "O:", "\\Mi servidor\DATA$"
        MapDrive "H:", "\\Mi servidor\APPS$"
      

     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     ' Display a greeting
     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     DisplayGreeting

    End Sub 'Configure PC

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Sub:  DisplayGreeting
    ' Description: Displays a user friendly greeting
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub DisplayGreeting

     Dim MyHour

     MyHour = Hour(Now)

     'Display greeting
     If (MyHour < 11) Then
      WScript.Echo "Buenos días " & UserName
     ElseIf (MyHour < 19) Then
      WScript.Echo "Buenas tardes " & UserName
     Else
      WScript.Echo "Buenas noches " & UserName
     End If

    End Sub

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function: MapDrive
    ' Arguments: Drive Letter (with ":") and Share Name on ShareSvr
    ' Description: Maps Share' mapping CANNOT exist already
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Sub MapDrive( strDrive, strShare )
     Dim Path
     If InStr(strShare,"\") then
      Path=strShare
     Else
      Path="\\" & ShareSvr & "\" & strShare
     End If

     ' Map drive
     On Error Resume Next
     WSHNetwork.MapNetworkDrive strDrive, Path

     ' End Sub result
     If Err.Number <> 0 Then
      WScript.Echo strUserID & ": Mapping " & strDrive & " to " & Path & " " & Err.Description & "(" & int(err.number) & ")" & Now()
     End If
    End Sub

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function: Check if user is in Group
    '
    ' Arguments: Group to check membership of
    '
    ' Note: Requires pre-initialization of UserGroups variant
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Function InGroup(strGroup)
         InGroup=False
         If InStr(UserGroups,"[" & strGroup & "]") Then
                   InGroup=True
         End If
    End Function

    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function: Create New User Environment Variable
    '
    ' Arguments: Variable Name
    '            Value To Set variable
    '
    ' Note: Requires shell object to be created
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Function CreateVariable(strVariable,strValeue)
    Dim colUsrEnvVars
     Set colUsrEnvVars = WshShell.Environment("USER")
     colUsrEnvVars(strVariable) = strValeue
    End Function
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Function: Add new search path to end of Path environment
    '           variable
    '
    ' Arguments: Path to add to search
    '
    ' Note: Requires shell object to be created &
    '       Network object to be created
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Function MapSearchPath(strNewPath)
     Dim colUsrEnvVars
     Dim strCurrentPath
     Dim MyPos
     
        MapDrive Chr(LastDrive) & ":",strNewPath
        LastDrive = LastDrive - 1    'decrement drive letter
     Set colUsrEnvVars = WshShell.Environment("USER")
     strCurrentPath = colUsrEnvVars("Path")
     strNewPath = chr(LastDrive) & ":" & strNewPath
     'This is not fool proof. Instr finds the fist occurence so it could be a substring
     MyPos = Instr(1, strCurrentPath, strNewPath, 1)
     If (MyPos = 0) or (MyPos = null) Then
      strNewPath = strCurrentPath & ";" & strNewPath
      colUsrEnvVars("Path") = strNewPath
     End If
    End Function

    martes, 26 de enero de 2010 20:58

Respuestas

Todas las respuestas