elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Habilitar conexión compartida a internet (ICS) con visual basic script
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Habilitar conexión compartida a internet (ICS) con visual basic script  (Leído 1,987 veces)
LordBynary

Desconectado Desconectado

Mensajes: 12


Ver Perfil
Habilitar conexión compartida a internet (ICS) con visual basic script
« en: 18 Diciembre 2012, 18:23 pm »

Hola a todos, les cuento que desde hace varios días vengo intentado resolver este problema que tengo, lo que pasa es que quiero poder habilitar las 2 opciones que aparecen de conexiones compartidas a internet (ICS) en las propiedades de algún adaptador de red, pero nosé si esto se pueda hacer mediante un script en vbs o mediante un script reg que odifique el regsitro, por favor alguien que me pueda ayudar a resolver mi problema se lo agradecerí muchísimo poque  he buscado y no he encontrado, pero creo que si se puede pero nosé como exactamente, bueno les agradecería su ayuda...

PD : es un reto para todos los que les gusta la programación en scripting y sobre todo los retos.


En línea

Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.809



Ver Perfil
Re: Habilitar conexión compartida a internet (ICS) con visual basic script
« Respuesta #1 en: 18 Diciembre 2012, 20:16 pm »

PD : es un reto para todos los que les gusta la programación en scripting y sobre todo los retos.
Para que molestarse en codearlo cuando ya está hecho xD.

Pruébalo pasándole los argumentos necesarios:

Código
  1. Originally from http://www.autoitscript.com/forum/topic/28897-switch-ics/
  2. 'Changed to VBS, added arguments and fixed for private/public networkds by Dror Gluska 2012-06-25
  3. 'Dror Gluska (2012) - http://uhurumkate.blogspot.co.il/
  4.  
  5.  
  6. option explicit
  7.  
  8.  
  9.  
  10. Main( )
  11.  
  12. sub Main( )
  13.    dim objArgs, con, endis,con2
  14.  
  15.    Set objArgs = WScript.Arguments
  16.  
  17.    'WScript.Echo objArgs.Count
  18.  
  19.    if objArgs.Count > 0 then
  20.        con = objArgs(0)
  21.        con2 = objArgs(1)
  22.        endis = objArgs(2)
  23.  
  24.        EnableDisableICS con,con2, endis 'true enables, false disables
  25.  
  26.    else
  27.        DIM szMsg
  28.        szMsg = "Invalid usage! Please provide the name of the connection as the argument." & vbCRLF & vbCRLF & _
  29.                "Usage:" & vbCRLF & _
  30.                " " + WScript.scriptname + " ""Public Connection Name"" ""Private Connection Name"" true/false"
  31.        WScript.Echo( szMsg )
  32.  
  33.    end if
  34.  
  35. end sub
  36.  
  37.  
  38.  
  39. function EnableDisableICS(sPublicConnectionName, sPrivateConnectionName, bEnable)
  40.  
  41.    dim bFound
  42.    bFound = FALSE
  43.    dim oNetSharingManager, oConnectionCollection, oItem, EveryConnection, objNCProps
  44.  
  45.    set oNetSharingManager = Wscript.CreateObject("HNetCfg.HNetShare.1")
  46.     if (IsObject(oNetSharingManager)) = FALSE then
  47.        Wscript.Echo("Unable to get the HNetCfg.HnetShare.1 object.")
  48.        Exit function
  49.    End if
  50.  
  51.    if (IsNull(oNetSharingManager.SharingInstalled) = TRUE) then
  52.        Wscript.Echo( "Sharing is not available on this platform.")
  53.        Exit function
  54.    End if
  55.  
  56.  
  57.  
  58.     set oConnectionCollection = oNetSharingManager.EnumEveryConnection
  59.    for each oItem In oConnectionCollection
  60.        set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem)
  61.        set objNCProps = oNetSharingManager.NetConnectionProps (oItem)
  62.         If objNCProps.name = sPrivateConnectionName Then
  63.            bFound = True
  64.           Wscript.Echo("Setting ICS Private to " & bEnable & " on connection: " & objNCProps.name)
  65.            If bEnable Then
  66.                EveryConnection.EnableSharing (1)
  67.            Else
  68.                EveryConnection.DisableSharing
  69.            End if
  70.        End if
  71.    Next
  72.  
  73.    set oConnectionCollection = oNetSharingManager.EnumEveryConnection
  74.    for each oItem In oConnectionCollection
  75.        set EveryConnection = oNetSharingManager.INetSharingConfigurationForINetConnection (oItem)
  76.        set objNCProps = oNetSharingManager.NetConnectionProps (oItem)
  77.  
  78.        If objNCProps.name = sPublicConnectionName Then
  79.            bFound = True
  80.           Wscript.Echo("Setting ICS Public to " & bEnable & " on connection: " & objNCProps.name)
  81.            If bEnable Then
  82.                EveryConnection.EnableSharing (0)
  83.            Else
  84.                EveryConnection.DisableSharing
  85.            End if
  86.        End if
  87.    next
  88.  
  89.    If Not bFound Then
  90.       Wscript.Echo("Unable to find the connection " & sPublicConnectionName)
  91.    End if
  92.  
  93. end function


En línea

LordBynary

Desconectado Desconectado

Mensajes: 12


Ver Perfil
Re: Habilitar conexión compartida a internet (ICS) con visual basic script
« Respuesta #2 en: 19 Diciembre 2012, 05:22 am »

Hola EleKtro H@cker bueno te agradezco por la informacion que me diste, pero tengo un problema, nosé que argumentos pasarle al script para que funcione correctamente porque creo q dice:

1.- nombre de la conexion publica
2.-nombre de la conexion privada
3.- y el valor para habilitarlo o deshabilitarlo

pero nosé en que parte del script poner esos argumentos y que valor debo poner en cada argumento, osea a que se refiere cada uno , si me darias un ejemplo con cada argumento que tengo q pasarle al srcipt para que funcione correctamente y en donde poner los argumentos te lo agradecería mucho...
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Conexion compartida a internet(via wifi)
Redes
Hacker wifi 2 6,963 Último mensaje 24 Junio 2010, 13:12 pm
por Hacker wifi
¿Script de conexión a BBDD?
Bases de Datos
martinillou 0 2,049 Último mensaje 15 Noviembre 2013, 11:48 am
por martinillou
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines