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

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


  Mostrar Mensajes
Páginas: 1 ... 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 [510] 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 ... 1236
5091  Foros Generales / Foro Libre / Re: Stop Yulin Festival en: 21 Junio 2015, 05:19 am
Engel lex: Te referirás a esta vaca verdad

¡Salvemos las vacas!. ¡NOW!.





















.
..
...excepto esta:




Muuuuu... :silbar:
5092  Foros Generales / Foro Libre / Re: Stop Yulin Festival en: 21 Junio 2015, 02:39 am
Yo----Yo si qeu intento no pisarlas y a veces les echo migas de pan, son animalitos que no hacen mal a nadie

Me parece admirable (sin sarcasmo), de hecho no me lo esperaba, aunque yo hago lo mismo con casi todo bicho viviente, pero a donde quería llegar a parar con ese comentario es que seguro que encontraría otro ejemplo donde harías todo lo contraría a intentar no matar sin querer o sin "pena", ya sea con ratas, cucarachas, arañas, serpientes, abejas, plantas, u otro ser vivo...

Un depredador mata o muere, un humano tiene alternativas

Por qué tú lo digas, Constance. El humano es un depredador, depredador adaptado a cualquier tipo de entorno, sigue siendo un depredador, no un Dios que pueda elegir no morir de hambruna sin matar.

Saludos!
5093  Foros Generales / Foro Libre / Re: Stop Yulin Festival en: 21 Junio 2015, 02:01 am
Imagina que alguien mata a tu perro , no sé si lo tienes y luego te dice que se lo ha comido porque no tenia nada que llevarse a la boca?
Qué harias? ....lo entenderías ??

Entenderlo si, ya que el ser humano debe alimentarse cómo carnívoro que es, ahora, ¿aceptarlo?, no, seguramente le rompería las dos piernas para dejarle paralítico y le haría una vasectomía, ya que en esas circunstancias se podría decir que ha matado a un miembro de mi familia (habiendo podido evitarlo comiendo cualquier otra cosa que no fuese mi perro).

Pero, es que ese tipo de argumento que das carece de sentido común, tú lo que haces es mezclar los sentimientos de pena, con las necesidades básicas de los seres vivos;
las hormigas también tienen familia que les espera en su hormiguero, y seguro que no andas por las calles mirando hacia el suelo para no pisar ninguna.

El hecho es que se está matando para alimentar a seres humanos, eso es lo único que tiene relevancia en este asunto ...indiferentemente de si ese perro es un perro vagabundo, o es un perro pérdido con una familia detrás que está esperando que regrese a su hogar (aunque, pobrecito en ese caso, da pena, lo se).

Hay muchas cosas que si estan mal y son inhumanas... particulármente las condiciones en que mantienen a esos perros, pero protestar por el hecho de comer carne (de perro, o de lo que sea), me parece absurdo, e hipócrita.

Saludos!
5094  Foros Generales / Foro Libre / Re: Stop Yulin Festival en: 21 Junio 2015, 01:47 am
hervirán vivos MILLONES DE PERROS para comerlos un sufrimiento inimaginable ..
esta ATROCIDAD

LOS PERROS Y GATOS, no son COMIDA , SON FAMILIA y AMIGOS

Tú misma lo has dicho, para comerlos, entonces, ¿donde está la atrocidad, Constance?.

Toda carne es comida para un ser carnívoro, ¿o vosotros, los "animalistas" cómo dices, qué soys? (aparte de pseudo-vegetarianos).

Si ese es el motivo de la recolecta de firmas, es decir, que "los perros y los gatos no son comida", entonces esto no tiene ni pies ni cabeza, es ridículo, si que son comida, y sino, mira a los chinos cómo comen.

¿?



pensad en vuestra mascota arrojada a un cacerola de agua hirviendo.. eso es lo que va a pasar con muchos inocentes

La cuestión es que en China, los perros sirven para ALIMENTAR a muchos seres humanos, muchos de los cuales tal vez no puedan llevarse ninguna otra cosa a la boca y se mueran de hambre, ah, pero claro... eso no le importa a los ""animalistas"", ¿verdad?. ( "salvemos a los perros y condenemos a los humanos" )

Ha sido un argumento algo extremo (aunque en esencia es eso, privar a los humanos de la comida para salvar a los animales), pero ahora intentaré hacerte reflexionar con algo más realista, a ti, y a todos...

Y dime tú, imaginate que realmente con esas firmas consiguierais algo, dime, ¿qué pasaría con todos esos cánidos y felinos si no se los comen en el festival?,
¿realmente crees que les esperaría un futuro mejor?, ¿DE VERDAD CREES QUE DETENER UN EVENTO CÓMO EL DE YULIN SIGNIFICA SALVAR VIDAS?,
¡No!, los perros y los gatos volverían a las jaulas para comerlos otro día, es decir, solo conseguiriais retrasar la muerte del animal, y eso significa alargar la agonia y el sufrimiento del animal,
no hay nada de bueno en ello (aparte de la intención), y por ese motivo yo jamás firmaría para algo así, a pesar de que soy un amante de los animales ...tengo mi cordura y creo estar usándola correcta y firmemente, algo que parece escasear en los argumentos de tú petición de firmas.



quien sabe si tendrán una oportunidad??

¿Una oportunidad de que?, por que una oportunidad de vivir ya te digo que no, todos esos perros ya están condenados, enjaulados.

¿Eso es lo que buscais con estas firmas, una oportunidad para el animal?

Si realmente quereis recolectar firmas para algo positivo, para un bien estar de los animales en general, entonces hacedlo para conseguir mejorar las condiciones en las que los chinos tratan (torturan) a los animales antes de comérselos, eso si que tiene delito, y no el hecho de comérselos, no me jodas, que eso es algo inevitable y natural, usemos un poco el razonamiento, el animal es carne, y la carne se come.

Doy por supuesto que nada de lo que he dicho servirá para que lo veas de otro modo, ya que.... la gente que piensa y actua de esta manera... la considero ciegos, pero bueno, yo ya lo he intentado.

A mi este tipo de cosas me fastidian mucho, por que con gente que hace estas cosas y actua sin pensar, al final el mundo va a la inversa, hacia el camino equivocado, eligiendo a partidos políticos equivocados, y consiguiendo perjudicar a los demás con una falsa sensación de estar haciendo lo correcto, cuando en realidad es todo lo contrario.

Mi opinión.

Saludos!
5095  Foros Generales / Foro Libre / Re: Stop Yulin Festival en: 21 Junio 2015, 01:08 am
Dime tú, imaginemos por un instante que realmente conseguiis detener el evento.

¿Qué crees que habreis conseguido al hacerlo?.

¿Por que debería una persona firmar para detener ese evento?,
¿qué razones me das para hacerlo? (ya que, que amemos a los perros por mascota no es una razón),
¿Qué beneficios le aportaría el anmal, si se detiene ese evento?.

¿El motivo principal por el que supuestamente debemos querer detener el evento es que: "Los perros y los gatos no son comida, son familia y amigos"?.
( Si es que a eso se le puede llamar motivo... )

A mi me parece que ni siquiera habeis pensado en los pros y/o los contras, ni en las consecuencias que tendría la detención de ese evento, que simplemente veis a un animal a la parrilla y ya no razonais, estos argumentos y esta "manifestación" me recuerdan a las femi-nazis, es decir, una tontería muy grande, pero bueno, te pregunto para estar seguro, a ver cuales son tus argumentos, antes de exponerte los mios para intentar demostrarte que esta recolecta de firma, a parte de no ser muy cuerda, es una muy mala idea.

Espero tu respuesta a todo esto.

PD: Un amante de los cánidos.

Saludos!
5096  Programación / Scripting / Re: Acciones sobre archivos de texto. [Batch] en: 21 Junio 2015, 00:31 am
Existe alguna forma de fucionar esos archivos de forma que las lineas queden en sus lugares correspondietes? Parecia algo bastante sencillo, pero el otro dia le di un millon de vueltas y no encotre ninguna forma.

En Batch sería algo MUY, MUY tedioso (e ineficiente) ya que no tiene soporte para Arrays; En cualquier otro lenguaje de verdad, sería algo muy sencillo.

Una manera general de llevar a cabo esa tarea sería iterar con un búcle las lineas de texto del primer archivo para añadir esas lineas a un Array, una vez hecho esto, ya tienes una colección indizada en la que poder comprobar si un elemento está vacío o no, para reemplazarlo/fusionarlo por el elemento con el mismo índice al iterar las lineas del segundo archivo.

Pseudo-Código:

Código:
declare linesCol(Array) = Null
declare mixedLinesCol(Array) = Null
declare index(Int32) = 0

For Each line(String) in textfile1.ReadToEnd:
    linesCol1(Index) = line
    Index += 1
End For

Index = 0 # Resetear el contador.
For each line(String) in textfile2.ReadToEnd:

    # Si la linea no está vacía, reemplazar por la linea original (o añadirla).
    if line.IsNotEmpty() Then
        linesCol1(Index) = line
    End If

    Index += 1
End For



Se que no es Batch, pero desarrollarlo en Batch sería perder el tiempo por que hay muchas mejores opciones, prefiero aportarte una alternativa mejor, mostrándote este código funcional (y eficiente) desarrollado en VB.NET:
Código
  1. Dim textLineCol1 As IEnumerable(Of String) =
  2.    File.ReadAllLines("Archivo 1.txt", Encoding.Default)
  3.  
  4. Dim textLineCol2 As IEnumerable(Of String) =
  5.    File.ReadAllLines("Archivo 2.txt", Encoding.Default)
  6.  
  7. Dim mixedLineCol As New List(Of String)
  8.  
  9. For index As Integer = 0 To (textLineCol2.Count - 1)
  10.  
  11.    Dim curLine As String = textLineCol2(index)
  12.  
  13.    If (textLineCol1.Count <= index) OrElse (Not String.IsNullOrWhiteSpace(curLine)) Then
  14.        mixedLineCol.Add(curLine)
  15.  
  16.    Else
  17.        mixedLineCol.Add(textLineCol1(index))
  18.  
  19.    End If
  20.  
  21. Next index
  22.  
  23. File.WriteAllLines("Fusionado.txt", mixedLineCol, Encoding.Default)

Archivo 1.txt:
Código
  1. Linea1
  2.  
  3. Linea 3
  4.  
  5. Linea 5

Archivo 2.txt:
Código
  1.  
  2. Linea 2
  3.  
  4. Linea 4
  5. Linea5 - Nueva
  6. Linea 6

Archivo Combinado.txt:
Código
  1. Linea1
  2. Linea 2
  3. Linea 3
  4. Linea 4
  5. Linea5 - Nueva
  6. Linea 6

Saludos!
5097  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets para VB.Net !! (Compartan aquí sus snippets) en: 20 Junio 2015, 19:50 pm
UserAccountUtil.vb, una class para realizar tareas comunes relacioandas con las cuentas de usuario (LOCALES) de Windows.

Diagrama de Class:


Código fuente:
Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 20-June-2015
  4. ' ***********************************************************************
  5. ' <copyright file="UserAccountUtil.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Public Members Summary "
  11.  
  12. #Region " Properties "
  13.  
  14. ' UserAccountUtil.CurrentUser As UserPrincipal
  15. ' UserAccountUtil.CurrentUserIsAdmin As Boolean
  16.  
  17. #End Region
  18.  
  19. #Region " Functions "
  20.  
  21. ' UserAccountUtil.Create(String, String, String, String, Boolean, Boolean) As UserPrincipal
  22. ' UserAccountUtil.FindProfilePath(SecurityIdentifier) As String
  23. ' UserAccountUtil.FindProfilePath(String) As String
  24. ' UserAccountUtil.FindSid(String) As SecurityIdentifier
  25. ' UserAccountUtil.FindUser(SecurityIdentifier) As UserPrincipal
  26. ' UserAccountUtil.FindUser(String) As UserPrincipal
  27. ' UserAccountUtil.FindUsername(SecurityIdentifier) As String
  28. ' UserAccountUtil.GetAllUsers() As List(Of UserPrincipal)
  29. ' UserAccountUtil.IsAdmin(String) As Boolean
  30. ' UserAccountUtil.IsMemberOfGroup(String, String) As Boolean
  31. ' UserAccountUtil.IsMemberOfGroup(String, WellKnownSidType) As Boolean
  32.  
  33. #End Region
  34.  
  35. #Region " Methods "
  36.  
  37. ' UserAccountUtil.Add(String, String, String, String, Boolean, Boolean, WellKnownSidType)
  38. ' UserAccountUtil.Add(UserPrincipal, WellKnownSidType)
  39. ' UserAccountUtil.Delete(String)
  40.  
  41. #End Region
  42.  
  43. #End Region
  44.  
  45. #Region " Option Statements "
  46.  
  47. Option Strict On
  48. Option Explicit On
  49. Option Infer Off
  50.  
  51. #End Region
  52.  
  53. #Region " Imports "
  54.  
  55. Imports System
  56. Imports System.Collections.Generic
  57. Imports System.DirectoryServices.AccountManagement
  58. Imports System.Linq
  59. Imports System.Security.Principal
  60.  
  61. #End Region
  62.  
  63. ''' <summary>
  64. ''' Contains related Windows user-account utilities.
  65. ''' </summary>
  66. Public NotInheritable Class UserAccountUtil
  67.  
  68. #Region " Properties "
  69.  
  70.    ''' ----------------------------------------------------------------------------------------------------
  71.    ''' <summary>
  72.    ''' Gets an <see cref="UserPrincipal"/> object that represents the current user.
  73.    ''' </summary>
  74.    ''' ----------------------------------------------------------------------------------------------------
  75.    ''' <value>
  76.    ''' An <see cref="UserPrincipal"/> object that represents the current user.
  77.    ''' </value>
  78.    ''' ----------------------------------------------------------------------------------------------------
  79.    Public Shared ReadOnly Property CurrentUser As UserPrincipal
  80.        Get
  81.            If UserAccountUtil.currentUserB Is Nothing Then
  82.                UserAccountUtil.currentUserB = UserAccountUtil.FindUser(Environment.UserName)
  83.            End If
  84.            Return UserAccountUtil.currentUserB
  85.        End Get
  86.    End Property
  87.    ''' <summary>
  88.    ''' (Backing Field)
  89.    ''' Gets an <see cref="UserPrincipal"/> object that represents the current user.
  90.    ''' </summary>
  91.    Private Shared currentUserB As UserPrincipal
  92.  
  93.    ''' ----------------------------------------------------------------------------------------------------
  94.    ''' <summary>
  95.    ''' Gets a value that indicates whether the current user has Administrator privileges.
  96.    ''' </summary>
  97.    ''' ----------------------------------------------------------------------------------------------------
  98.    ''' <value>
  99.    ''' A value that indicates whether the current user has Administrator privileges.
  100.    ''' </value>
  101.    ''' ----------------------------------------------------------------------------------------------------
  102.    Public Shared ReadOnly Property CurrentUserIsAdmin As Boolean
  103.        Get
  104.            Using group As GroupPrincipal =
  105.                GroupPrincipal.FindByIdentity(CurrentUser.Context,
  106.                                              IdentityType.Sid,
  107.                                              New SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, Nothing).Value)
  108.  
  109.                Return UserAccountUtil.CurrentUser.IsMemberOf(group)
  110.            End Using
  111.        End Get
  112.    End Property
  113.  
  114. #End Region
  115.  
  116. #Region " Constructors "
  117.  
  118.    ''' <summary>
  119.    ''' Prevents a default instance of the <see cref="UserAccountUtil"/> class from being created.
  120.    ''' </summary>
  121.    Private Sub New()
  122.    End Sub
  123.  
  124. #End Region
  125.  
  126. #Region " Public Methods "
  127.  
  128.    ''' ----------------------------------------------------------------------------------------------------
  129.    ''' <remarks>
  130.    ''' Title : Get all user-accounts.
  131.    ''' Author: Elektro
  132.    ''' Date  : 20-June-2015
  133.    ''' </remarks>
  134.    ''' ----------------------------------------------------------------------------------------------------
  135.    ''' <example>
  136.    ''' Dim users As List(Of UserPrincipal) = UserAccountUtil.GetAllUsers()
  137.    ''' </example>
  138.    ''' ----------------------------------------------------------------------------------------------------
  139.    ''' <summary>
  140.    ''' Find and returns all the user accounts of the current machine context.
  141.    ''' </summary>
  142.    ''' ----------------------------------------------------------------------------------------------------
  143.    ''' <returns>
  144.    ''' A <see cref="List(Of UserPrincipal)"/> collection that contains the users.
  145.    ''' </returns>
  146.    ''' ----------------------------------------------------------------------------------------------------
  147.    <DebuggerStepThrough>
  148.    Public Shared Function GetAllUsers() As List(Of UserPrincipal)
  149.  
  150.        Dim context As New PrincipalContext(ContextType.Machine)
  151.  
  152.        Using user As New UserPrincipal(context)
  153.  
  154.            Using searcher As New PrincipalSearcher(user)
  155.  
  156.                Return searcher.FindAll.Cast(Of UserPrincipal).ToList
  157.  
  158.            End Using ' searcher
  159.  
  160.        End Using ' user
  161.  
  162.    End Function
  163.  
  164.    ''' ----------------------------------------------------------------------------------------------------
  165.    ''' <remarks>
  166.    ''' Title : Find user-account by name.
  167.    ''' Author: Elektro
  168.    ''' Date  : 19-June-2015
  169.    ''' </remarks>
  170.    ''' ----------------------------------------------------------------------------------------------------
  171.    ''' <example>
  172.    ''' Dim user As UserPrincipal = UserAccountUtil.FindUser(username:="Administrator")
  173.    ''' </example>
  174.    ''' ----------------------------------------------------------------------------------------------------
  175.    ''' <summary>
  176.    ''' Finds an user account that matches the specified name in the current machine context.
  177.    ''' </summary>
  178.    ''' ----------------------------------------------------------------------------------------------------
  179.    ''' <param name="username">
  180.    ''' The user name to find.
  181.    ''' </param>
  182.    ''' ----------------------------------------------------------------------------------------------------
  183.    ''' <returns>
  184.    ''' An <see cref="UserPrincipal"/> object that contains the user data.
  185.    ''' </returns>
  186.    ''' ----------------------------------------------------------------------------------------------------
  187.    ''' <exception cref="ArgumentException">
  188.    ''' User not found.;username
  189.    ''' </exception>
  190.    ''' ----------------------------------------------------------------------------------------------------
  191.    <DebuggerStepThrough>
  192.    Public Shared Function FindUser(ByVal username As String) As UserPrincipal
  193.  
  194.        Dim context As New PrincipalContext(ContextType.Machine)
  195.  
  196.        Using user As New UserPrincipal(context)
  197.  
  198.            Using searcher As New PrincipalSearcher(user)
  199.  
  200.                Try
  201.                    Return (From p As Principal In searcher.FindAll
  202.                            Where p.Name.Equals(username, StringComparison.OrdinalIgnoreCase)).
  203.                            Cast(Of UserPrincipal).
  204.                            First
  205.  
  206.                Catch ex As InvalidOperationException
  207.                    Throw New ArgumentException(message:="User not found.", paramName:="username", innerException:=ex)
  208.  
  209.                End Try
  210.  
  211.            End Using ' searcher
  212.  
  213.        End Using ' user
  214.  
  215.    End Function
  216.  
  217.    ''' ----------------------------------------------------------------------------------------------------
  218.    ''' <remarks>
  219.    ''' Title : Find user-account by SID.
  220.    ''' Author: Elektro
  221.    ''' Date  : 19-June-2015
  222.    ''' </remarks>
  223.    ''' ----------------------------------------------------------------------------------------------------
  224.    ''' <example>
  225.    ''' Dim user As UserPrincipal = UserAccountUtil.FindUser(sid:=New SecurityIdentifier("S-1-5-21-1780771175-1208154119-2269826705-500"))
  226.    ''' </example>
  227.    ''' ----------------------------------------------------------------------------------------------------
  228.    ''' <summary>
  229.    ''' Finds an user account that matches the specified security identifier (SID) in the current machine context.
  230.    ''' </summary>
  231.    ''' ----------------------------------------------------------------------------------------------------
  232.    ''' <param name="sid">
  233.    ''' A <see cref="SecurityIdentifier"/> (SID) object.
  234.    ''' </param>
  235.    ''' ----------------------------------------------------------------------------------------------------
  236.    ''' <returns>
  237.    ''' An <see cref="UserPrincipal"/> object that contains the user data.
  238.    ''' </returns>
  239.    ''' ----------------------------------------------------------------------------------------------------
  240.    <DebuggerStepThrough>
  241.    Public Shared Function FindUser(ByVal sid As SecurityIdentifier) As UserPrincipal
  242.  
  243.        Dim context As New PrincipalContext(ContextType.Machine)
  244.  
  245.        Using user As New UserPrincipal(context)
  246.  
  247.            Using searcher As New PrincipalSearcher(user)
  248.  
  249.                Try
  250.                    Return (From p As Principal In searcher.FindAll
  251.                            Where p.Sid.Value.Equals(sid.Value, StringComparison.OrdinalIgnoreCase)).
  252.                            Cast(Of UserPrincipal).
  253.                            First
  254.  
  255.                Catch ex As InvalidOperationException
  256.                    Throw New ArgumentException(message:="User not found.", paramName:="username", innerException:=ex)
  257.  
  258.                End Try
  259.  
  260.            End Using ' searcher
  261.  
  262.        End Using ' user
  263.  
  264.    End Function
  265.  
  266.    ''' ----------------------------------------------------------------------------------------------------
  267.    ''' <remarks>
  268.    ''' Title : Find user-account name by SID.
  269.    ''' Author: Elektro
  270.    ''' Date  : 19-June-2015
  271.    ''' </remarks>
  272.    ''' ----------------------------------------------------------------------------------------------------
  273.    ''' <example>
  274.    ''' Dim username As String = UserAccountUtil.FindUsername(sid:=New SecurityIdentifier("S-1-5-21-1780771175-1208154119-2269826705-500"))
  275.    ''' </example>
  276.    ''' ----------------------------------------------------------------------------------------------------
  277.    ''' <summary>
  278.    ''' Finds the username of the specified security identifier (SID) in the current machine context.
  279.    ''' </summary>
  280.    ''' ----------------------------------------------------------------------------------------------------
  281.    ''' <param name="sid">
  282.    ''' A <see cref="SecurityIdentifier"/> (SID) object.
  283.    ''' </param>
  284.    ''' ----------------------------------------------------------------------------------------------------
  285.    ''' <returns>
  286.    ''' The username.
  287.    ''' </returns>
  288.    ''' ----------------------------------------------------------------------------------------------------
  289.    <DebuggerStepThrough>
  290.    Public Shared Function FindUsername(ByVal sid As SecurityIdentifier) As String
  291.  
  292.        Using user As UserPrincipal = UserAccountUtil.FindUser(sid)
  293.  
  294.            Return user.Name
  295.  
  296.        End Using
  297.  
  298.    End Function
  299.  
  300.    ''' ----------------------------------------------------------------------------------------------------
  301.    ''' <remarks>
  302.    ''' Title : Find user-account SID by username.
  303.    ''' Author: Elektro
  304.    ''' Date  : 19-June-2015
  305.    ''' </remarks>
  306.    ''' ----------------------------------------------------------------------------------------------------
  307.    ''' <example>
  308.    ''' Dim sid As SecurityIdentifier = UserAccountUtil.FindSid(username:="Administrator"))
  309.    ''' </example>
  310.    ''' ----------------------------------------------------------------------------------------------------
  311.    ''' <summary>
  312.    ''' Finds the security identifier (SID) of the specified username account in the current machine context.
  313.    ''' </summary>
  314.    ''' ----------------------------------------------------------------------------------------------------
  315.    ''' <param name="username">
  316.    ''' The user name.
  317.    ''' </param>
  318.    ''' ----------------------------------------------------------------------------------------------------
  319.    ''' <returns>
  320.    ''' A <see cref="SecurityIdentifier"/> (SID) object.
  321.    ''' </returns>
  322.    ''' ----------------------------------------------------------------------------------------------------
  323.    <DebuggerStepThrough>
  324.    Public Shared Function FindSid(ByVal username As String) As SecurityIdentifier
  325.  
  326.        Return UserAccountUtil.FindUser(username).Sid
  327.  
  328.    End Function
  329.  
  330.    ''' ----------------------------------------------------------------------------------------------------
  331.    ''' <remarks>
  332.    ''' Title : Find user-account's profile path by username.
  333.    ''' Author: Elektro
  334.    ''' Date  : 19-June-2015
  335.    ''' </remarks>
  336.    ''' ----------------------------------------------------------------------------------------------------
  337.    ''' <example>
  338.    ''' Dim profilePath As String = UserAccountUtil.FindProfilePath(username:="Administrator"))
  339.    ''' </example>
  340.    ''' ----------------------------------------------------------------------------------------------------
  341.    ''' <summary>
  342.    ''' Finds the profile directory path of the specified username account in the current machine context.
  343.    ''' </summary>
  344.    ''' ----------------------------------------------------------------------------------------------------
  345.    ''' <param name="username">
  346.    ''' The user name to find.
  347.    ''' </param>
  348.    ''' ----------------------------------------------------------------------------------------------------
  349.    ''' <returns>
  350.    ''' The profile directory path.
  351.    ''' </returns>
  352.    ''' ----------------------------------------------------------------------------------------------------
  353.    <DebuggerStepThrough>
  354.    Public Shared Function FindProfilePath(ByVal userName As String) As String
  355.  
  356.        Using user As UserPrincipal = UserAccountUtil.FindUser(userName)
  357.  
  358.            Return CStr(My.Computer.Registry.GetValue(String.Format("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\{0}",
  359.                                                                    user.Sid.Value),
  360.                                                                    "ProfileImagePath", ""))
  361.  
  362.        End Using
  363.  
  364.    End Function
  365.  
  366.    ''' ----------------------------------------------------------------------------------------------------
  367.    ''' <remarks>
  368.    ''' Title : Find user-account's profile path by SID.
  369.    ''' Author: Elektro
  370.    ''' Date  : 19-June-2015
  371.    ''' </remarks>
  372.    ''' ----------------------------------------------------------------------------------------------------
  373.    ''' <example>
  374.    ''' Dim profilePath As String = UserAccountUtil.FindProfilePath(sid:=New SecurityIdentifier("S-1-5-21-1780771175-1208154119-2269826705-500"))
  375.    ''' </example>
  376.    ''' ----------------------------------------------------------------------------------------------------
  377.    ''' <summary>
  378.    ''' Finds the profile directory path of the specified username account in the current machine context.
  379.    ''' </summary>
  380.    ''' ----------------------------------------------------------------------------------------------------
  381.    ''' <param name="sid">
  382.    ''' A <see cref="SecurityIdentifier"/> (SID) object.
  383.    ''' </param>
  384.    ''' ----------------------------------------------------------------------------------------------------
  385.    ''' <returns>
  386.    ''' The profile directory path.
  387.    ''' </returns>
  388.    ''' ----------------------------------------------------------------------------------------------------
  389.    <DebuggerStepThrough>
  390.    Public Shared Function FindProfilePath(ByVal sid As SecurityIdentifier) As String
  391.  
  392.        Using user As UserPrincipal = UserAccountUtil.FindUser(sid)
  393.  
  394.            Return CStr(My.Computer.Registry.GetValue(String.Format("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\{0}",
  395.                                                                    user.Sid.Value),
  396.                                                                    "ProfileImagePath", ""))
  397.  
  398.        End Using
  399.  
  400.    End Function
  401.  
  402.    ''' ----------------------------------------------------------------------------------------------------
  403.    ''' <remarks>
  404.    ''' Title : User is Admin?.
  405.    ''' Author: Elektro
  406.    ''' Date  : 19-June-2015
  407.    ''' </remarks>
  408.    ''' ----------------------------------------------------------------------------------------------------
  409.    ''' <example>
  410.    ''' Dim userIsAdmin As Boolean = UserAccountUtil.IsAdmin(username:="Administrator")
  411.    ''' </example>
  412.    ''' ----------------------------------------------------------------------------------------------------
  413.    ''' <summary>
  414.    ''' Determines whether an user-account of the current machine context is an Administrator.
  415.    ''' </summary>
  416.    ''' ----------------------------------------------------------------------------------------------------
  417.    ''' <param name="username">
  418.    ''' The user name.
  419.    ''' </param>
  420.    ''' ----------------------------------------------------------------------------------------------------
  421.    ''' <returns>
  422.    ''' <c>True</c> if the user is an Administrator, otherwise, <c>False</c>.
  423.    ''' </returns>
  424.    ''' ----------------------------------------------------------------------------------------------------
  425.    <DebuggerStepThrough>
  426.    Public Shared Function IsAdmin(ByVal username As String) As Boolean
  427.  
  428.        Using user As UserPrincipal = UserAccountUtil.FindUser(username)
  429.  
  430.            Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(user.Context, IdentityType.Sid, New SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, Nothing).Value)
  431.  
  432.                Return user.IsMemberOf(group)
  433.  
  434.            End Using ' group
  435.  
  436.        End Using ' user
  437.  
  438.    End Function
  439.  
  440.    ''' ----------------------------------------------------------------------------------------------------
  441.    ''' <remarks>
  442.    ''' Title : User is member of group...?.
  443.    ''' Author: Elektro
  444.    ''' Date  : 19-June-2015
  445.    ''' </remarks>
  446.    ''' ----------------------------------------------------------------------------------------------------
  447.    ''' <example>
  448.    ''' Dim userIsGuest As Boolean = UserAccountUtil.IsMemberOfGroup(username:="Administrator", groupSid:=WellKnownSidType.BuiltinGuestsSid)
  449.    ''' </example>
  450.    ''' ----------------------------------------------------------------------------------------------------
  451.    ''' <summary>
  452.    ''' Determines whether an user-account of the current machine context is a member of the specified group.
  453.    ''' </summary>
  454.    ''' ----------------------------------------------------------------------------------------------------
  455.    ''' <param name="username">
  456.    ''' The user name.
  457.    ''' </param>
  458.    '''
  459.    ''' <param name="groupSid">
  460.    ''' A <see cref="WellKnownSidType"/> security identifier (SID) that determines the account group.
  461.    ''' </param>
  462.    ''' ----------------------------------------------------------------------------------------------------
  463.    ''' <returns>
  464.    ''' <c>True</c> if the user is a member of the specified group, otherwise, <c>False</c>.
  465.    ''' </returns>
  466.    ''' ----------------------------------------------------------------------------------------------------
  467.    <DebuggerStepThrough>
  468.    Public Shared Function IsMemberOfGroup(ByVal username As String,
  469.                                           ByVal groupSid As WellKnownSidType) As Boolean
  470.  
  471.        Using user As UserPrincipal = UserAccountUtil.FindUser(username)
  472.  
  473.            Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(user.Context, IdentityType.Sid, New SecurityIdentifier(groupSid, Nothing).Value)
  474.  
  475.                Return user.IsMemberOf(group)
  476.  
  477.            End Using ' group
  478.  
  479.        End Using ' user
  480.  
  481.    End Function
  482.  
  483.    ''' ----------------------------------------------------------------------------------------------------
  484.    ''' <remarks>
  485.    ''' Title : User is member of group...?.
  486.    ''' Author: Elektro
  487.    ''' Date  : 19-June-2015
  488.    ''' </remarks>
  489.    ''' ----------------------------------------------------------------------------------------------------
  490.    ''' <example>
  491.    ''' Dim userIsGuest As Boolean = UserAccountUtil.IsMemberOfGroup(username:="Administrator", groupname:="Guests")
  492.    ''' </example>
  493.    ''' ----------------------------------------------------------------------------------------------------
  494.    ''' <summary>
  495.    ''' Determines whether an user-account of the current machine context is a member of the specified group.
  496.    ''' </summary>
  497.    ''' ----------------------------------------------------------------------------------------------------
  498.    ''' <param name="username">
  499.    ''' The user name.
  500.    ''' </param>
  501.    '''
  502.    ''' <param name="groupname">
  503.    ''' The name of thehe group.
  504.    ''' </param>
  505.    ''' ----------------------------------------------------------------------------------------------------
  506.    ''' <returns>
  507.    ''' <c>True</c> if the user is a member of the specified group, otherwise, <c>False</c>.
  508.    ''' </returns>
  509.    ''' ----------------------------------------------------------------------------------------------------
  510.    <DebuggerStepThrough>
  511.    Public Shared Function IsMemberOfGroup(ByVal username As String,
  512.                                           ByVal groupname As String) As Boolean
  513.  
  514.        Using user As UserPrincipal = UserAccountUtil.FindUser(username)
  515.  
  516.            Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(user.Context, IdentityType.Name, groupname)
  517.  
  518.                Return user.IsMemberOf(group)
  519.  
  520.            End Using ' group
  521.  
  522.        End Using ' user
  523.  
  524.    End Function
  525.  
  526.    ''' ----------------------------------------------------------------------------------------------------
  527.    ''' <remarks>
  528.    ''' Title : Create user-account.
  529.    ''' Author: Elektro
  530.    ''' Date  : 19-June-2015
  531.    ''' </remarks>
  532.    ''' ----------------------------------------------------------------------------------------------------
  533.    ''' <example>
  534.    ''' Dim user as UserPrincipal = UserAccountUtil.Create(username:="Elektro",
  535.    '''                                                    password:="",
  536.    '''                                                    displayName:="Elektro Account.",
  537.    '''                                                    description:="This is a test user-account.",
  538.    '''                                                    canChangePwd:=True,
  539.    '''                                                    pwdExpires:=False,
  540.    '''                                                    groupSid:=WellKnownSidType.BuiltinAdministratorsSid)
  541.    ''' </example>
  542.    ''' ----------------------------------------------------------------------------------------------------
  543.    ''' <summary>
  544.    ''' Creates a new user account in the current machine context.
  545.    ''' This function does NOT adds a new user in the current machine.
  546.    ''' </summary>
  547.    ''' ----------------------------------------------------------------------------------------------------
  548.    ''' <param name="username">
  549.    ''' The user name.
  550.    ''' </param>
  551.    '''
  552.    ''' <param name="password">
  553.    ''' The user password.
  554.    ''' If this value is empty, account is set to don't require any password.
  555.    ''' </param>
  556.    '''
  557.    ''' <param name="displayName">
  558.    ''' The display name of the user account.
  559.    ''' </param>
  560.    '''
  561.    ''' <param name="description">
  562.    ''' The description of the user account.
  563.    ''' </param>
  564.    '''
  565.    ''' <param name="canChangePwd">
  566.    ''' A value that indicates whether the user can change its password.
  567.    ''' </param>
  568.    '''
  569.    ''' <param name="pwdExpires">
  570.    ''' A value that indicates whether the password should expire.
  571.    ''' </param>
  572.    ''' ----------------------------------------------------------------------------------------------------
  573.    ''' <returns>
  574.    ''' An <see cref="UserPrincipal"/> object that contains the user data.
  575.    ''' </returns>
  576.    ''' ----------------------------------------------------------------------------------------------------
  577.    <DebuggerStepThrough>
  578.    Public Shared Function Create(ByVal username As String,
  579.                                  ByVal password As String,
  580.                                  ByVal displayName As String,
  581.                                  ByVal description As String,
  582.                                  ByVal canChangePwd As Boolean,
  583.                                  ByVal pwdExpires As Boolean) As UserPrincipal
  584.  
  585.        Using context As New PrincipalContext(ContextType.Machine)
  586.  
  587.            Dim user As New UserPrincipal(context)
  588.  
  589.            With user
  590.  
  591.                .Name = username
  592.  
  593.                .SetPassword(password)
  594.                .PasswordNotRequired = String.IsNullOrEmpty(password)
  595.  
  596.                .DisplayName = displayName
  597.                .Description = description
  598.  
  599.                .UserCannotChangePassword = canChangePwd
  600.                .PasswordNeverExpires = pwdExpires
  601.  
  602.                .Enabled = True
  603.                .Save()
  604.  
  605.            End With
  606.  
  607.            Return user
  608.  
  609.        End Using
  610.  
  611.    End Function
  612.  
  613.    ''' ----------------------------------------------------------------------------------------------------
  614.    ''' <remarks>
  615.    ''' Title : Add user-account.
  616.    ''' Author: Elektro
  617.    ''' Date  : 19-June-2015
  618.    ''' </remarks>
  619.    ''' ----------------------------------------------------------------------------------------------------
  620.    ''' <example>
  621.    ''' UserAccountUtil.Add(username:="Elektro",
  622.    '''                     password:="",
  623.    '''                     displayName:="Elektro Account.",
  624.    '''                     description:="This is a test user-account.",
  625.    '''                     canChangePwd:=True,
  626.    '''                     pwdExpires:=False,
  627.    '''                     groupSid:=WellKnownSidType.BuiltinAdministratorsSid)
  628.    ''' </example>
  629.    ''' ----------------------------------------------------------------------------------------------------
  630.    ''' <summary>
  631.    ''' Adds a new user account in the current machine context.
  632.    ''' </summary>
  633.    ''' ----------------------------------------------------------------------------------------------------
  634.    ''' <param name="username">
  635.    ''' The user name.
  636.    ''' </param>
  637.    '''
  638.    ''' <param name="password">
  639.    ''' The user password.
  640.    ''' If this value is empty, account is set to don't require any password.
  641.    ''' </param>
  642.    '''
  643.    ''' <param name="displayName">
  644.    ''' The display name of the user account.
  645.    ''' </param>
  646.    '''
  647.    ''' <param name="description">
  648.    ''' The description of the user account.
  649.    ''' </param>
  650.    '''
  651.    ''' <param name="canChangePwd">
  652.    ''' A value that indicates whether the user can change its password.
  653.    ''' </param>
  654.    '''
  655.    ''' <param name="pwdExpires">
  656.    ''' A value that indicates whether the password should expire.
  657.    ''' </param>
  658.    '''
  659.    ''' <param name="groupSid">
  660.    ''' A <see cref="WellKnownSidType"/> security identifier (SID) that determines the account group where to add the user.
  661.    ''' </param>
  662.    ''' ----------------------------------------------------------------------------------------------------
  663.    <DebuggerStepThrough>
  664.    Public Shared Sub Add(ByVal username As String,
  665.                          ByVal password As String,
  666.                          ByVal displayName As String,
  667.                          ByVal description As String,
  668.                          ByVal canChangePwd As Boolean,
  669.                          ByVal pwdExpires As Boolean,
  670.                          Optional ByVal groupSid As WellKnownSidType = WellKnownSidType.BuiltinUsersSid)
  671.  
  672.        Using context As New PrincipalContext(ContextType.Machine)
  673.  
  674.            Using user As UserPrincipal = UserAccountUtil.Create(username, password, displayName, description, canChangePwd, pwdExpires)
  675.  
  676.                Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(context, IdentityType.Sid, New SecurityIdentifier(groupSid, Nothing).Value)
  677.  
  678.                    group.Members.Add(user)
  679.                    group.Save()
  680.  
  681.                End Using ' group
  682.  
  683.            End Using ' user
  684.  
  685.        End Using ' context
  686.  
  687.    End Sub
  688.  
  689.    ''' ----------------------------------------------------------------------------------------------------
  690.    ''' <remarks>
  691.    ''' Title : Add user-account.
  692.    ''' Author: Elektro
  693.    ''' Date  : 19-June-2015
  694.    ''' </remarks>
  695.    ''' ----------------------------------------------------------------------------------------------------
  696.    ''' <example>
  697.    ''' UserAccountUtil.Add(user:=myUserPrincipal, groupSid:=WellKnownSidType.BuiltinAdministratorsSid)
  698.    ''' </example>
  699.    ''' ----------------------------------------------------------------------------------------------------
  700.    ''' <summary>
  701.    ''' Adds a new user account in the current machine context.
  702.    ''' </summary>
  703.    ''' ----------------------------------------------------------------------------------------------------
  704.    ''' <param name="user">
  705.    ''' An <see cref="UserPrincipal"/> object that contains the user data.
  706.    ''' </param>
  707.    '''
  708.    ''' <param name="groupSid">
  709.    ''' A <see cref="WellKnownSidType"/> security identifier (SID) that determines the account group where to add the user.
  710.    ''' </param>
  711.    ''' ----------------------------------------------------------------------------------------------------
  712.    <DebuggerStepThrough>
  713.    Public Shared Sub Add(ByVal user As UserPrincipal,
  714.                          Optional ByVal groupSid As WellKnownSidType = WellKnownSidType.BuiltinUsersSid)
  715.  
  716.        Using context As New PrincipalContext(ContextType.Machine)
  717.  
  718.            Using group As GroupPrincipal = GroupPrincipal.FindByIdentity(context, IdentityType.Sid, New SecurityIdentifier(groupSid, Nothing).Value)
  719.  
  720.                group.Members.Add(user)
  721.                group.Save()
  722.  
  723.            End Using ' group
  724.  
  725.        End Using ' context
  726.  
  727.    End Sub
  728.  
  729.    ''' ----------------------------------------------------------------------------------------------------
  730.    ''' <remarks>
  731.    ''' Title : Delete user-account.
  732.    ''' Author: Elektro
  733.    ''' Date  : 19-June-2015
  734.    ''' </remarks>
  735.    ''' ----------------------------------------------------------------------------------------------------
  736.    ''' <example>
  737.    ''' UserAccountUtil.Delete(username:="User name")
  738.    ''' </example>
  739.    ''' ----------------------------------------------------------------------------------------------------
  740.    ''' <summary>
  741.    ''' Deletes an user account in the current machine context.
  742.    ''' </summary>
  743.    ''' ----------------------------------------------------------------------------------------------------
  744.    ''' <param name="username">
  745.    ''' The user name of the user-account to delete.
  746.    ''' </param>
  747.    ''' ----------------------------------------------------------------------------------------------------
  748.    ''' <exception cref="ArgumentException">
  749.    ''' User not found.;username
  750.    ''' </exception>
  751.    ''' ----------------------------------------------------------------------------------------------------
  752.    <DebuggerStepThrough>
  753.    Public Shared Sub Delete(ByVal username As String)
  754.  
  755.        Using curUser As UserPrincipal = UserAccountUtil.FindUser(username)
  756.  
  757.            curUser.Delete()
  758.  
  759.        End Using
  760.  
  761.    End Sub
  762.  
  763. #End Region
  764.  
  765. End Class
  766.  
5098  Programación / Scripting / Re: Cargar fichero TXT y asignarle a cada linea, una variable. -- VBS -- en: 20 Junio 2015, 18:37 pm
El planteamiento de tú código es incorrecto, ¿qué ocurre si por ejemplo el valor de una de las variables contiene un símbolo "="?.

Aquí te escribo este ejemplo para crear variables dinámicamente.
Código
  1. Option explicit : Dim file, curLine, curIndex, _
  2.                      varPreffix, varName, varValue
  3.  
  4. ' Defino un prefijo para el nombre de las variabes dinámicas.
  5. varPreffix = "var"
  6.  
  7. ' Instancio el Stream del objeto que lee el archivo de texto.
  8. Set file = CreateObject("Scripting.FileSystemObject"). _
  9.                        OpenTextFile("Archivo.txt", 1)
  10.  
  11. ' Itero las lineas del archivo.
  12. Do Until file.AtEndOfStream
  13.  
  14.    curIndex = (curIndex + 1)
  15.    curLine  = file.Readline
  16.  
  17.    ' varName  = Trim(Mid(curLine, 1, InStr(curLine, "=") - 1))
  18.    varValue = Trim(Mid(curLine,    InStr(curLine, "=") + 1))
  19.  
  20.    ' Creo la variable dinamicamente.
  21.    ExecuteGlobal varPreffix & curIndex & "=" & """" & varValue & """"
  22.  
  23.    ' Muestro el nombre de la variable y el valor.
  24.    Execute "WSCript.Echo varPreffix & curIndex & ""="" & " & varPreffix & curIndex
  25.  
  26.    ' En resumen, para acceder mediante un índice:
  27.    ' ExecuteGlobal "WScript.Echo " & varPreffix & curIndex
  28.  
  29. Loop
  30.  
  31. ' Cierro el Stream.
  32. file.Close()
  33.  
  34. WScript.Quit(0)

Resultado de ejecución:
Código:
Cscript.exe /NoLogo "Archivo.vbs"

var1=espanha
var2=madrid
var3=win7
var4=ie9
var5=11

Saludos
5099  Programación / .NET (C#, VB.NET, ASP) / Re: Listar procesos en listview. en: 20 Junio 2015, 08:58 am
la primera no termino de entender muy bien

Ejemplo:
Código
  1. Dim lvItems As New List(Of ListViewDataItem)
  2.  
  3. For Each p As Process In Process.GetProcesses()
  4.  
  5.    Using lvItem As New ListViewDataItem
  6.  
  7.        With lvItem
  8.            .Item(0) = p.Id
  9.            .Item(1) = p.ProcessName
  10.        End With
  11.  
  12.        lvItems.Add(lvItem)
  13.  
  14.    End Using
  15.  
  16. Next p
  17.  
  18. With Me.RadListView1
  19.    .Columns.Add("PID")
  20.    .Columns.Add("Process Name")
  21.    .ViewType = ListViewType.DetailsView
  22.  
  23.    .Items.AddRange(lvItems.ToArray)
  24. End With

Saludos!
5100  Programación / .NET (C#, VB.NET, ASP) / Re: Listar procesos en listview. en: 20 Junio 2015, 07:32 am
Código
  1. Dim lvlItem As New ListViewDataItem()
  2.  
  3. For Each procesos In Process.GetProcesses()
  4.    Me.ListaProcesos.Items.Add(lvlItem)
  5.    lvlItem.Item(0) = procesos.Id  'ha la columna 1 le asigno el id de los procesos
  6.    lvlItem.Item(1) = procesos.ProcessName 'ha la columna 2 le asigno el nombre
  7. Next

Estás manipulando siempre la misma referencia, es decir, estás reemplazando los valores en el mismo objeto todo el rato.

Instancia un objeto del tipo ListViewDataItem para cada item y resolverás el problema.

O añade directamente los valores "id" y "Processname" a la colección RadListView1.Items, usando el overload de los métodos Add o AddRange que toman cómo argumento un Array de objetos.

Saludos!
Páginas: 1 ... 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 [510] 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines