none
Script VBS para mapeo entre varios Proxy RRS feed

  • Debate general


  • '*********************************************************************************
    ' Inicio del Login Script Global
    '*********************************************************************************
    Option Explicit
    On Error Resume Next
    '*********************************************************************************
    ' Definicion de variables
    '*********************************************************************************
    Dim WSHNetwork, FSO, strUserName, strUserDomain, ObjGroupDict, objDisk, objNetwork, objWMIService, colDisks, WshShell
    '*********************************************************************************
    ' Seto de Variables
    '*********************************************************************************
    Set WSHNetwork = WScript.CreateObject("WScript.Network")
    Set FSO = CreateObject("Scripting.FileSystemObject")
    strUserName = ""
    While strUserName = ""
    WScript.Sleep 100 ' 1/10 th of a second
    strUserName = WSHNetwork.UserName
    Wend
    strUserDomain = WSHNetwork.UserDomain
    Set ObjGroupDict = CreateMemberOfObject(strUserDomain, strUserName)
    Set objNetwork = CreateObject("Wscript.Network")
    Set objWMIService = GetObject("winmgmts:\root\cimv2")
    Set colDisks = objWMIService.ExecQuery("Select * from Win32_LogicalDisk")
    Set WshShell = CreateObject("WScript.Shell")
    Set WshShell = WScript.CreateObject("WScript.Shell")

    If MemberOf(ObjGroupDict, "prueba1") Then
    WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", "Server.dominio.com.ar:8080"
    WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
    WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyOverride", "*10.1.100.*;10.1.2.*;10.1.120.*;192.168.80.*;10.1.104.23;10.1.108.53*"
    else
    If MemberOf(ObjGroupDict, "prueba2") Then
    WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer", "Server.dominio.com.ar:8080"
    WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 1, "REG_DWORD"
    WSHShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyOverride", "*10.1.120.*;192.168.80.*;10.1.104.23;10.1.108.53*"
    End if
    End if

    '********************************************************************************
    'Funciones
    '********************************************************************************
    Function MemberOf(ObjDict, strKey)
    MemberOf = CBool(ObjGroupDict.Exists(strKey))
    End Function

    Function CreateMemberOfObject(strDomain, strUserName)
    Dim objUser, objGroup
    Set CreateMemberOfObject = CreateObject("Scripting.Dictionary")
    CreateMemberOfObject.CompareMode = vbTextCompare
    Set objUser = GetObject("LDAP://" _
    & strDomain & "/" _
    & strUserName & ",user")
    For Each objGroup In objUser.Groups
    CreateMemberOfObject.Add objGroup.Name, "-"
    Next
    Set objUser = Nothing
    End Function
    '********************************************************************************
    'Sub-Rutina Elimino Unidades de Red
    '********************************************************************************
    Sub Remove_Old_Drives()
    For each objDisk in colDisks
    If objDisk.DriveType = 4 And objDisk.Name > "F:" Then
    objNetwork.RemoveNetworkDrive objDisk.Name, True, True
    End If
    Next
    End Sub


    Gaston A. Gimené - MCP(MCTS) MCTS: Microsoft Certified Technology Specialist

    jueves, 10 de enero de 2013 14:27