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


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Mensajes
Páginas: 1 ... 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 [751] 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 ... 1252
7501  Programación / Scripting / Re: No me deja instalar id3 mass tagger en: 8 Marzo 2014, 16:39 pm
Ahora si, gracias, con el source ya te puedo ayudar.

El problema es que la unidad D: no existe y no se puede encontrar, lo más probable es que al reinstalar Windows este te haya modificado la letra de dicha unidad.

Si escribes una unidad que no existe (Ej: "Z:"), precísamente lanza el mismo error que comentaste:

Cita de: CMD
Código:
c:\>Z:

El sistema no puede encontrar el controlador especificado.


Haz la modificación necearia a la letra de la unidad, y para evitar futuros errores te sugiero reemplazar el comando:
Código:
d:

Por este otro:
Código:
PUSHD "D:"  2>NUL || (Echo No existe la unidad & Pause&Exit /B 1)

(óbviamente, como ya digo, debes asignarle la letra de unidad correcta al comando)


Saludos!
7502  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Compartan aquí sus snippets) en: 8 Marzo 2014, 15:41 pm

Un ejemplo de uso muy básico de la librería NCalc ~> http://ncalc.codeplex.com/

Código
  1.        Dim MathExpression As String = "(2 + 3) * 2" ' Result: 10
  2.  
  3.        Dim NCalcExpression As New NCalc.Expression(MathExpression)
  4.  
  5.        MsgBox(NCalcExpression.Evaluate().ToString)





Una forma de comprobar si un archivo es un ensamblado .NET:

Código
  1.    ' Usage Examples:
  2.    '
  3.    ' MsgBox(IsNetAssembly("C:\File.exe"))
  4.    ' MsgBox(IsNetAssembly("C:\File.dll"))
  5.  
  6.    ''' <summary>
  7.    ''' Gets the common language runtime (CLR) version information of the specified file, using the specified buffer.
  8.    ''' </summary>
  9.    ''' <param name="filepath">Indicates the filepath of the file to be examined.</param>
  10.    ''' <param name="buffer">Indicates the buffer allocated for the version information that is returned.</param>
  11.    ''' <param name="buflen">Indicates the size, in wide characters, of the buffer.</param>
  12.    ''' <param name="written">Indicates the size, in bytes, of the returned buffer.</param>
  13.    ''' <returns>System.Int32.</returns>
  14.    <System.Runtime.InteropServices.DllImport("mscoree.dll",
  15.    CharSet:=System.Runtime.InteropServices.CharSet.Unicode)>
  16.    Private Shared Function GetFileVersion(
  17.                      ByVal filepath As String,
  18.                      ByVal buffer As System.Text.StringBuilder,
  19.                      ByVal buflen As Integer,
  20.                      ByRef written As Integer
  21.    ) As Integer
  22.    End Function
  23.  
  24.    ''' <summary>
  25.    ''' Determines whether an exe/dll file is an .Net assembly.
  26.    ''' </summary>
  27.    ''' <param name="File">Indicates the exe/dll file to check.</param>
  28.    ''' <returns><c>true</c> if file is an .Net assembly; otherwise, <c>false</c>.</returns>
  29.    Public Shared Function IsNetAssembly(ByVal [File] As String) As Boolean
  30.  
  31.        Dim sb = New System.Text.StringBuilder(256)
  32.        Dim written As Integer = 0
  33.        Dim hr = GetFileVersion([File], sb, sb.Capacity, written)
  34.        Return hr = 0
  35.  
  36.    End Function





Un simple efecto de máquina de escribir:

Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 03-08-2014
  4. ' ***********************************************************************
  5. ' <copyright file="TypeWritter.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Usage Examples "
  11.  
  12. 'Sub Main()
  13.  
  14. '    Console.WriteLine()
  15. '    TypeWritter.WriteLine("[ Typewritter ] - By Elektro")
  16. '    TypeWritter.WriteLine()
  17. '    TypeWritter.WriteLine()
  18. '    TypeWritter.WriteLine("Hola a todos!, les presento este humilde y simple efecto de máquina de escribir")
  19. '    TypeWritter.WriteLine()
  20. '    TypeWritter.WriteLine("Si os fijais aténtamente, quizás ya habreis notado, que hay pausas realistas,   al escribir signos de puntuación...")
  21. '    TypeWritter.WriteLine()
  22. '    TypeWritter.WriteLine("[+] Podemos establecer la velocidad de escritura, por ejemplo, a 20 ms. :")
  23. '    TypeWritter.WriteLine("abcdefghijklmnopqrstuvwxyz", 20)
  24. '    TypeWritter.WriteLine()
  25. '    TypeWritter.WriteLine("[+] Podemos establecer la velocidad de las pausas, por ejemplo, a 2 seg. :")
  26. '    TypeWritter.WriteLine(".,;:", , 2 * 1000)
  27. '    TypeWritter.WriteLine()
  28. '    TypeWritter.WriteLine("[+] El efecto corre en una tarea asíncrona, por lo que se pueden hacer otras cosas mientras tanto, sin frezzear una GUI, y también podemos cancelar la escritura en cualquier momento, gracias al Token de cancelación.")
  29. '    TypeWritter.WriteLine()
  30. '    TypeWritter.WriteLine()
  31. '    TypeWritter.WriteLine("Esto es todo por ahora.")
  32. '    Console.ReadKey()
  33.  
  34. 'End Sub
  35.  
  36. #End Region
  37.  
  38. #Region " TypeWritter "
  39.  
  40. ''' <summary>
  41. ''' Simulates text-typying effect like a Typewritter.
  42. ''' </summary>
  43. Public Class TypeWritter
  44.  
  45. #Region " Properties "
  46.  
  47.    ''' <summary>
  48.    ''' When set to 'True', the running 'Typewritter' task will be cancelled.
  49.    ''' ( The property is set again to 'False' automatically after a 'Task' is cancelled )
  50.    ''' </summary>
  51.    Public Shared Property RequestCancel As Boolean = False
  52.  
  53. #End Region
  54.  
  55. #Region " Task Objects "
  56.  
  57.    ''' <summary>
  58.    ''' The typewritter asynchronous Task.
  59.    ''' </summary>
  60.    Private Shared TypeWritterTask As Threading.Tasks.Task
  61.  
  62.    ''' <summary>
  63.    ''' The typewritter Task Cancellation TokenSource.
  64.    ''' </summary>
  65.    Private Shared TypeWritterTaskCTS As New Threading.CancellationTokenSource
  66.  
  67.    ''' <summary>
  68.    ''' The typewritter Task Cancellation Token.
  69.    ''' </summary>
  70.    Private Shared TypeWritterTaskCT As Threading.CancellationToken = TypeWritterTaskCTS.Token
  71.  
  72. #End Region
  73.  
  74. #Region " Private Methods "
  75.  
  76.    ''' <summary>
  77.    ''' Writes text simulating a Typewritter effect.
  78.    ''' </summary>
  79.    ''' <param name="CancellationToken">Indicates the cancellation token of the Task.</param>
  80.    ''' <param name="Text">Indicates the text to type.</param>
  81.    ''' <param name="TypeSpeed">Indicates the typying speed, in ms.</param>
  82.    ''' <param name="PauseDuration">Indicates the pause duration of the punctuation characters, in ms.</param>
  83.    Private Shared Sub TypeWritter(ByVal CancellationToken As Threading.CancellationToken,
  84.                            ByVal [Text] As String,
  85.                            ByVal TypeSpeed As Integer,
  86.                            ByVal PauseDuration As Integer)
  87.  
  88.        ' If Text is empty then write an empty line...
  89.        If String.IsNullOrEmpty([Text]) Then
  90.  
  91.            ' If not cancellation is already requested then...
  92.            If Not CancellationToken.IsCancellationRequested Then
  93.  
  94.                ' Write an empty line.
  95.                Console.WriteLine()
  96.  
  97.                ' Wait-Speed (empty line).
  98.                Threading.Thread.Sleep(PauseDuration)
  99.  
  100.            End If ' CancellationToken.IsCancellationRequested
  101.  
  102.        End If ' String.IsNullOrEmpty([Text])
  103.  
  104.        ' For each Character in Text to type...
  105.        For Each c As Char In [Text]
  106.  
  107.            ' If not cancellation is already requested then...
  108.            If Not CancellationToken.IsCancellationRequested Then
  109.  
  110.                ' Type the character.
  111.                Console.Write(CStr(c))
  112.  
  113.                ' Type-Wait.
  114.                Threading.Thread.Sleep(TypeSpeed)
  115.  
  116.                If ".,;:".Contains(c) Then
  117.                    ' Pause-Wait.
  118.                    Threading.Thread.Sleep(PauseDuration)
  119.                End If
  120.  
  121.            Else ' want to cancel.
  122.  
  123.                ' Exit iteration.
  124.                Exit For
  125.  
  126.            End If ' CancellationToken.IsCancellationRequested
  127.  
  128.        Next c ' As Char In [Text]
  129.  
  130.    End Sub
  131.  
  132. #End Region
  133.  
  134. #Region " Public Methods "
  135.  
  136.    ''' <summary>
  137.    ''' Writes text simulating a Typewritter effect.
  138.    ''' </summary>
  139.    ''' <param name="Text">Indicates the text to type.</param>
  140.    ''' <param name="TypeSpeed">Indicates the typying speed, in ms.</param>
  141.    ''' <param name="PauseDuration">Indicates the pause duration of the punctuation characters, in ms.</param>
  142.    Public Shared Sub Write(ByVal [Text] As String,
  143.                            Optional ByVal TypeSpeed As Integer = 75,
  144.                            Optional ByVal PauseDuration As Integer = 400)
  145.  
  146.        ' Run the asynchronous Task.
  147.        TypeWritterTask = Threading.Tasks.
  148.                   Task.Factory.StartNew(Sub()
  149.                                             TypeWritter(TypeWritterTaskCT, [Text], TypeSpeed, PauseDuration)
  150.                                         End Sub, TypeWritterTaskCT)
  151.  
  152.        ' Until Task is not completed or is not cancelled, do...
  153.        Do Until TypeWritterTask.IsCompleted OrElse TypeWritterTask.IsCanceled
  154.  
  155.            ' If want to cancel then...
  156.            If RequestCancel Then
  157.  
  158.                ' If not cancellation is already requested then...
  159.                If Not TypeWritterTaskCTS.IsCancellationRequested Then
  160.  
  161.                    ' Cancel the Task.
  162.                    TypeWritterTaskCTS.Cancel()
  163.  
  164.                    ' Renew the cancellation token and tokensource.
  165.                    TypeWritterTaskCTS = New Threading.CancellationTokenSource
  166.                    TypeWritterTaskCT = TypeWritterTaskCTS.Token
  167.  
  168.                End If
  169.  
  170.                ' Reset the cancellation flag var.
  171.                RequestCancel = False
  172.  
  173.                ' Exit iteration.
  174.                Exit Do
  175.  
  176.            End If
  177.  
  178.        Loop ' TypeTask.IsCompleted OrElse TypeTask.IsCanceled
  179.  
  180.    End Sub
  181.  
  182.    ''' <summary>
  183.    ''' Writes text simulating a Typewritter effect, and adds a break-line at the end.
  184.    ''' </summary>
  185.    ''' <param name="Text">Indicates the text to type.</param>
  186.    ''' <param name="TypeSpeed">Indicates the typying speed, in ms.</param>
  187.    ''' <param name="PauseDuration">Indicates the pause duration of the punctuation characters, in ms.</param>
  188.    Public Shared Sub WriteLine(ByVal [Text] As String,
  189.                                Optional ByVal TypeSpeed As Integer = 75,
  190.                                Optional ByVal PauseDuration As Integer = 400)
  191.  
  192.        Write([Text], TypeSpeed, PauseDuration)
  193.        Console.WriteLine()
  194.  
  195.    End Sub
  196.  
  197.    ''' <summary>
  198.    ''' Writes an empty line.
  199.    ''' </summary>
  200.    ''' <param name="PauseDuration">Indicates the pause duration of the empty line, in ms.</param>
  201.    Public Shared Sub WriteLine(Optional ByVal PauseDuration As Integer = 750)
  202.  
  203.        Write(String.Empty, 1, PauseDuration)
  204.  
  205.    End Sub
  206.  
  207. #End Region
  208.  
  209. End Class
  210.  
  211. #End Region
7503  Programación / Scripting / Re: No me deja instalar id3 mass tagger en: 8 Marzo 2014, 04:24 am
De verdad, yo no se en que piensan ustedes cuando invierten su tiempo en formular una pregunta para pedir ayuda, ya que se ponen a hacerlo, ¿que menos que hacerlo bien?.

Hablas sobre un programa obsoleto (muerto) y underground, teniendo eso en cuenta, como mínimo deberías especificar:
· de donde lo descargaste
· versión del programa
· el SO donde lo utilizas (aunque sea obvio)


Además de eso hay ciertos datos fundamentales que se deben proporcionar para formular una duda sobre un lenguaje (no por que lo diga yo ni las normas, sinó por pura lógica si ustedes esperan recibir ayudar):
· el lenguaje que utilizas
· los detalles mínimos del error
· el código que utiizas


Pero aun así, sin aportar a tu duda toda esa información, ¿esperas que alguien te entienda y te pueda ofrecer ayuda sin más?, ¿de verdad lo esperas?.

...Bueno, por pura casualidad yo sé de que programa hablas ya que he usado ese tipo de herramientas durante gran parte de mi vida, dudo que más de 5 personas en todo el foro conozcan o hayan usado ese programa, deberías plantearte mejor la información que porporcionas en los posts que formules en el futuro.





el id3 mass tagger se distribuía como una aplicación de interface commandline (antes de morir), es decir, no se distribuia como un instalador, así que esto no me cuadra, ya que no tiene ningún sentido este error si no existe ningún instalador:
Citar
"no se pudo instalar hubo un error".
...Y tampoco das muchos detalles sobre donde te aparece ese mensaje ni de donde lo descargaste ...ni nada.

Citar
Código:
El sistema no puede hallar el controlador especificado.
id3: no files matching 35_PISTA.mp3

Un output sin el código no sirve de mucho....

De todas formas el error parece suceder antes de que tu Script procese la orden que ejecuta al id3.exe, ya que parece que el id3.exe se inicializa corréctamente porque este llama al método que procesa los parámetros que le enviaste para buscar archivos mp3, y te da la respuesta, así que si el error crítico fuese del id3.exe, lo más normal sería que finalizase la ejecución del programa, pero el output indica que no finalizó.

Así que, en mi opinión, no creo que el problema se del id3, los errores que tienes parecen estar más bien relacionados con componentes perdidos/corruptos en Windows, todo parece apuntar a que te falta alguna dll (controlador) inexistente en tu PC, y eso me lleva a pensar... ¿Te has instalado el típico y dañino Windows Lite?.

PD: Yo siempre he usado sin problemas el id3 mass tagger en Win Vista, 7, 8, y 8.1.

Saludos
7504  Programación / Scripting / Re: [DUDA] Batch o FTP en: 8 Marzo 2014, 02:02 am
La imagen de error sin la linea que lanza el error no sirve para nada, ¿Nos muestras lo que hay en la linea 3 del código?  :¬¬

De todas formas, el error se explica por si mismo, no tienes los permisos de usuario necesarios para realizar "X" acción (acción que se realiza en la linea 3).

Imagino que la linea 3 de tu código será la misma que esta:
Citar
Código:
Set objFile = objFSO.CreateTextFile(outFile,True)


Saludos
7505  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Compartan aquí sus snippets) en: 7 Marzo 2014, 19:52 pm
Algunos métodos de uso genérico sobre las cuentas de usuario.




Código
  1.    ' Get UserNames
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'System.DirectoryServices.AccountManagement'.
  6.    ' 2. Imports System.DirectoryServices.AccountManagement
  7.    '
  8.    ' Example Usages:
  9.    ' Dim UserNames As String() = GetUserNames()
  10.    '
  11.    ''' <summary>
  12.    ''' Get the username accounts of the current machine.
  13.    ''' </summary>
  14.    ''' <returns>System.String[][].</returns>
  15.    Public Function GetUserNames() As String()
  16.  
  17.        Dim pContext As New PrincipalContext(ContextType.Machine)
  18.        Dim pUser As New UserPrincipal(pContext)
  19.        Dim pSearcher As New PrincipalSearcher(pUser)
  20.        Dim UserNames As String() = (From u As Principal In pSearcher.FindAll Select u.Name).ToArray
  21.  
  22.        pContext.Dispose()
  23.        pSearcher.Dispose()
  24.        pUser.Dispose()
  25.  
  26.        Return UserNames
  27.  
  28.    End Function



Código
  1.    ' Get Users
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'System.DirectoryServices.AccountManagement'.
  6.    ' 2. Imports System.DirectoryServices.AccountManagement
  7.    '
  8.    ' Example Usages:
  9.    ' Dim Users As Principal() = GetUsers()
  10.    ' For Each User As Principal In Users()
  11.    '     MsgBox(User.Name)
  12.    ' Next
  13.    '
  14.    ''' <summary>
  15.    ''' Get the users of the current machine.
  16.    ''' </summary>
  17.    ''' <returns>Principal[][].</returns>
  18.    Public Function GetUsers() As Principal()
  19.  
  20.        Dim pContext As New PrincipalContext(ContextType.Machine)
  21.        Dim pUser As New UserPrincipal(pContext)
  22.        Dim pSearcher As New PrincipalSearcher(pUser)
  23.        Dim Users As Principal() = (From User As Principal In pSearcher.FindAll).ToArray
  24.  
  25.        Return Users
  26.  
  27.    End Function



Código
  1.   ' Delete User Account
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'System.DirectoryServices.AccountManagement'.
  6.    ' 2. Imports System.DirectoryServices.AccountManagement
  7.    '
  8.    ' Example Usages:
  9.    ' DeleteUserAccount("Username")
  10.    ' DeleteUserAccount(New Security.Principal.SecurityIdentifier("S-1-5-21-250596608-219436059-1115792336-500"))
  11.    '
  12.    ''' <summary>
  13.    ''' Deletes an existing user account in the current machine.
  14.    ''' </summary>
  15.    ''' <param name="UserName">Indicates the account Username.</param>
  16.    ''' <returns><c>true</c> if deletion success, <c>false</c> otherwise.</returns>
  17.    Public Function DeleteUserAccount(ByVal UserName As String) As Boolean
  18.  
  19.        Dim pContext As New PrincipalContext(ContextType.Machine)
  20.        Dim pUser As New UserPrincipal(pContext)
  21.        Dim pSearcher As New PrincipalSearcher(pUser)
  22.  
  23.        Dim User As Principal =
  24.            (From u As Principal In pSearcher.FindAll
  25.            Where u.Name.Equals(UserName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault
  26.  
  27.        If User Is Nothing Then
  28.            Throw New Exception(String.Format("User with name '{0}' not found.", UserName))
  29.        End If
  30.  
  31.        Try
  32.            User.Delete()
  33.            Return True
  34.  
  35.        Catch ex As InvalidOperationException
  36.            Throw New Exception(ex.Message)
  37.  
  38.        Finally
  39.            pContext.Dispose()
  40.            pSearcher.Dispose()
  41.            pUser.Dispose()
  42.  
  43.        End Try
  44.  
  45.        Return False ' Failed.
  46.  
  47.    End Function

Código
  1.    ''' <summary>
  2.    ''' Deletes an existing user account in the current machine.
  3.    ''' </summary>
  4.    ''' <param name="UserSID">Indicates the account security identifier (SID).</param>
  5.    ''' <returns><c>true</c> if deletion success, <c>false</c> otherwise.</returns>
  6.    Public Function DeleteUserAccount(ByVal UserSID As Security.Principal.SecurityIdentifier) As Boolean
  7.  
  8.        Dim pContext As New PrincipalContext(ContextType.Machine)
  9.        Dim pUser As New UserPrincipal(pContext)
  10.        Dim pSearcher As New PrincipalSearcher(pUser)
  11.  
  12.        Dim User As Principal =
  13.            (From u As Principal In pSearcher.FindAll
  14.            Where u.Sid = UserSID).FirstOrDefault
  15.  
  16.        If User Is Nothing Then
  17.            Throw New Exception(String.Format("User with SID '{0}' not found.", UserSID.Value))
  18.        End If
  19.  
  20.        Try
  21.            User.Delete()
  22.            Return True
  23.  
  24.        Catch ex As InvalidOperationException
  25.            Throw New Exception(ex.Message)
  26.  
  27.        Finally
  28.            pContext.Dispose()
  29.            pSearcher.Dispose()
  30.            pUser.Dispose()
  31.  
  32.        End Try
  33.  
  34.        Return False ' Failed.
  35.  
  36.    End Function



Código
  1.    ' User Is Admin?
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'System.DirectoryServices.AccountManagement'.
  6.    ' 2. Imports System.DirectoryServices.AccountManagement
  7.    '
  8.    ' Example Usages:
  9.    ' MsgBox(UserIsAdmin("Administrador"))
  10.    ' MsgBox(UserIsAdmin(New Security.Principal.SecurityIdentifier("S-1-5-21-250596608-219436059-1115792336-500")))
  11.    '
  12.    ''' <summary>
  13.    ''' Determines whether an User is an Administrator.
  14.    ''' </summary>
  15.    ''' <param name="UserName">Indicates the account Username.</param>
  16.    ''' <returns><c>true</c> if user is an Administrator, <c>false</c> otherwise.</returns>
  17.    Public Function UserIsAdmin(ByVal UserName As String) As Boolean
  18.  
  19.        Dim AdminGroupSID As New SecurityIdentifier("S-1-5-32-544")
  20.  
  21.        Dim pContext As New PrincipalContext(ContextType.Machine)
  22.        Dim pUser As New UserPrincipal(pContext)
  23.        Dim pSearcher As New PrincipalSearcher(pUser)
  24.  
  25.        Dim User As Principal =
  26.            (From u As Principal In pSearcher.FindAll
  27.            Where u.Name.Equals(UserName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault
  28.  
  29.        If User Is Nothing Then
  30.            Throw New Exception(String.Format("User with name '{0}' not found.", UserName))
  31.        End If
  32.  
  33.        Dim IsAdmin As Boolean =
  34.            (From Group As GroupPrincipal In User.GetGroups
  35.             Where Group.Sid = AdminGroupSID).Any
  36.  
  37.        pContext.Dispose()
  38.        pSearcher.Dispose()
  39.        pUser.Dispose()
  40.  
  41.        Return IsAdmin
  42.  
  43.    End Function

Código
  1.    ''' <summary>
  2.    ''' Determines whether an User is an Administrator.
  3.    ''' </summary>
  4.    ''' <param name="UserSID">Indicates the SID of the user account.</param>
  5.    ''' <returns><c>true</c> if user is an Administrator, <c>false</c> otherwise.</returns>
  6.    Public Function UserIsAdmin(ByVal UserSID As Security.Principal.SecurityIdentifier) As Boolean
  7.  
  8.        Dim AdminGroupSID As New SecurityIdentifier("S-1-5-32-544")
  9.  
  10.        Dim pContext As New PrincipalContext(ContextType.Machine)
  11.        Dim pUser As New UserPrincipal(pContext)
  12.        Dim pSearcher As New PrincipalSearcher(pUser)
  13.  
  14.        Dim User As Principal =
  15.            (From u As Principal In pSearcher.FindAll
  16.            Where u.Sid = UserSID).FirstOrDefault
  17.  
  18.        If User Is Nothing Then
  19.            Throw New Exception(String.Format("User with SID '{0}' not found.", UserSID.Value))
  20.        End If
  21.  
  22.        Dim IsAdmin As Boolean =
  23.            (From Group As GroupPrincipal In User.GetGroups
  24.             Where Group.Sid = AdminGroupSID).Any
  25.  
  26.        pContext.Dispose()
  27.        pSearcher.Dispose()
  28.        pUser.Dispose()
  29.  
  30.        Return IsAdmin
  31.  
  32.    End Function



Código
  1.   ' Set UserName
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'System.DirectoryServices.AccountManagement'.
  6.    ' 2. Imports System.DirectoryServices.AccountManagement
  7.    '
  8.    ' Example Usages:
  9.    ' SetUserName("Username", "New Name")
  10.    ' SetUserName(New Security.Principal.SecurityIdentifier("S-1-5-21-250596608-219436059-1115792336-500"), "New Name")
  11.    '
  12.    ''' <summary>
  13.    ''' Sets the UserName of an existing User account.
  14.    ''' </summary>
  15.    ''' <param name="OldUserName">Indicates an existing username account.</param>
  16.    ''' <param name="NewUserName">Indicates the new name for the user account.</param>
  17.    ''' <returns><c>true</c> if change success, <c>false</c> otherwise.</returns>
  18.    Public Function SetUserName(ByVal OldUserName As String,
  19.                                ByVal NewUserName As String) As Boolean
  20.  
  21.        Dim pContext As New PrincipalContext(ContextType.Machine)
  22.        Dim pUser As New UserPrincipal(pContext)
  23.        Dim pSearcher As New PrincipalSearcher(pUser)
  24.  
  25.        Dim User As Principal =
  26.            (From u As Principal In pSearcher.FindAll
  27.            Where u.Name.Equals(OldUserName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault
  28.  
  29.        If User Is Nothing Then
  30.            Throw New Exception(String.Format("User with name '{0}' not found.", OldUserName))
  31.        End If
  32.  
  33.        Try
  34.            User.Name = NewUserName
  35.            User.Save()
  36.            Return True
  37.  
  38.        Catch ex As InvalidOperationException
  39.            Throw New Exception(ex.Message)
  40.  
  41.        Finally
  42.            pContext.Dispose()
  43.            pSearcher.Dispose()
  44.            pUser.Dispose()
  45.  
  46.        End Try
  47.  
  48.        Return False ' Failed.
  49.  
  50.    End Function

Código
  1.    ''' <summary>
  2.    ''' Sets the UserName of an existing User account.
  3.    ''' </summary>
  4.    ''' <param name="UserSID">Indicates the SID of the user account.</param>
  5.    ''' <param name="NewUserName">Indicates the new name for the user account.</param>
  6.    ''' <returns><c>true</c> if change success, <c>false</c> otherwise.</returns>
  7.    Public Function SetUserName(ByVal UserSID As Security.Principal.SecurityIdentifier,
  8.                                ByVal NewUserName As String) As Boolean
  9.  
  10.        Dim pContext As New PrincipalContext(ContextType.Machine)
  11.        Dim pUser As New UserPrincipal(pContext)
  12.        Dim pSearcher As New PrincipalSearcher(pUser)
  13.  
  14.        Dim User As Principal =
  15.            (From u As Principal In pSearcher.FindAll
  16.            Where u.Sid = UserSID).FirstOrDefault
  17.  
  18.        If User Is Nothing Then
  19.            Throw New Exception(String.Format("User with SID '{0}' not found.", UserSID.Value))
  20.        End If
  21.  
  22.        Try
  23.            User.Name = NewUserName
  24.            User.Save()
  25.            Return True
  26.  
  27.        Catch ex As InvalidOperationException
  28.            Throw New Exception(ex.Message)
  29.  
  30.        Finally
  31.            pContext.Dispose()
  32.            pSearcher.Dispose()
  33.            pUser.Dispose()
  34.  
  35.        End Try
  36.  
  37.        Return False ' Failed.
  38.  
  39.    End Function
  40.  


Código
  1.   ' Set Account DisplayName
  2.    ' ( By Elektro )
  3.    '
  4.    ' Instructions:
  5.    ' 1. Add a reference to 'System.DirectoryServices.AccountManagement'.
  6.    ' 2. Imports System.DirectoryServices.AccountManagement
  7.    '
  8.    ' Example Usages:
  9.    ' SetAccountDisplayName("Username", "New Name")
  10.    ' SetAccountDisplayName(New Security.Principal.SecurityIdentifier("S-1-5-21-250596608-219436059-1115792336-500"), "New Name")
  11.    '
  12.    ''' <summary>
  13.    ''' Sets the display name of an existing User account.
  14.    ''' </summary>
  15.    ''' <param name="OldDisplayName">Indicates an existing display name user account.</param>
  16.    ''' <param name="NewDisplayName">Indicates the new display name for the user account.</param>
  17.    ''' <returns><c>true</c> if change success, <c>false</c> otherwise.</returns>
  18.    Public Function SetAccountDisplayName(ByVal OldDisplayName As String,
  19.                                          ByVal NewDisplayName As String) As Boolean
  20.  
  21.        Dim pContext As New PrincipalContext(ContextType.Machine)
  22.        Dim pUser As New UserPrincipal(pContext)
  23.        Dim pSearcher As New PrincipalSearcher(pUser)
  24.  
  25.        Dim User As Principal =
  26.            (From u As Principal In pSearcher.FindAll
  27.            Where u.Name.Equals(OldDisplayName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault
  28.  
  29.        If User Is Nothing Then
  30.            Throw New Exception(String.Format("User with display name '{0}' not found.", OldDisplayName))
  31.        End If
  32.  
  33.        Try
  34.            User.DisplayName = NewDisplayName
  35.            User.Save()
  36.            Return True
  37.  
  38.        Catch ex As InvalidOperationException
  39.            Throw New Exception(ex.Message)
  40.  
  41.        Finally
  42.            pContext.Dispose()
  43.            pSearcher.Dispose()
  44.            pUser.Dispose()
  45.  
  46.        End Try
  47.  
  48.        Return False ' Failed.
  49.  
  50.    End Function

Código
  1.    ''' <summary>
  2.    ''' Sets the display name of an existing User account.
  3.    ''' </summary>
  4.    ''' <param name="UserSID">Indicates the SID of the user account.</param>
  5.    ''' <param name="NewDisplayName">Indicates the new display name for the user account.</param>
  6.    ''' <returns><c>true</c> if change success, <c>false</c> otherwise.</returns>
  7.    Public Function SetAccountDisplayName(ByVal UserSID As Security.Principal.SecurityIdentifier,
  8.                                          ByVal NewDisplayName As String) As Boolean
  9.  
  10.        Dim pContext As New PrincipalContext(ContextType.Machine)
  11.        Dim pUser As New UserPrincipal(pContext)
  12.        Dim pSearcher As New PrincipalSearcher(pUser)
  13.  
  14.        Dim User As Principal =
  15.            (From u As Principal In pSearcher.FindAll
  16.            Where u.Sid = UserSID).FirstOrDefault
  17.  
  18.        If User Is Nothing Then
  19.            Throw New Exception(String.Format("User with SID '{0}' not found.", UserSID.Value))
  20.        End If
  21.  
  22.        Try
  23.            User.DisplayName = NewDisplayName
  24.            User.Save()
  25.            Return True
  26.  
  27.        Catch ex As InvalidOperationException
  28.            Throw New Exception(ex.Message)
  29.  
  30.        Finally
  31.            pContext.Dispose()
  32.            pSearcher.Dispose()
  33.            pUser.Dispose()
  34.  
  35.        End Try
  36.  
  37.        Return False ' Failed.
  38.  
  39.    End Function
7506  Programación / Scripting / Re: [DUDA] Batch o FTP en: 7 Marzo 2014, 19:13 pm
haciendo ping si no me equivoco a x direccion te devolvia tu IP publica o algo asi

En todo caso, devolverá la IP por la que viaja el Ping.

No creo que en Batch se pueda obtener la IP pública de un router.

PD: Aprovecho para repetir que no contesto a mensajes privados pidiendo ayuda, usen el foro, @KZN.

Saludos
7507  Foros Generales / Dudas Generales / Re: Quien sabe de hackear flash,html? en: 7 Marzo 2014, 02:59 am
Si, ya ..."recuperar".

Parece que a pesar de los años todos siguen como locos por intentar "hackear" ese juego...

PD: Porfavor, lee las reglas de la comunidad, no está permitido duplicar posts.

Suerte con la "recuperación",
Saludos!
7508  Foros Generales / Dudas Generales / Re: Timostar a lo suyo... en: 7 Marzo 2014, 01:57 am
Yo tengo ganas de una cosa "asín"...

http://www.iber-banda.es/

Donde yo vivo hace 3 años no llegaba el adsl por cable e Iberbanda era la única opción disponible.
El servicio era (y sigue siendo) penoso.
Cuando llegó el adsl convencional todo el mundo les dió con la puerta en las narices.

No es por mal meter, pero ...es que no hay más que contemplar la página web tan profesional que tienen! (sarcasmo), inspira mucha confianza, pero sobretodo alucino con el anuncio tan currado que hicieron en Flash, con esos efectos de texto tan ...épicos, cuanto esfuerzo y dedicación para llevar a cabo esa animación, que digo, esa obra maestra!, es toda una proeza, y quien lo hiciera es un digno rival ...para mi abuela.

Saludos!
7509  Programación / Programación General / Re: ayuda con python: user y contraseña en: 6 Marzo 2014, 23:43 pm
otra cosa... veo que has utilizado el in en vez del != o ==,y que para marcar el nombre ' en vez del "...,hay diferencia en el lenguaje al usarlo?

Ya que te pones a programar en un lenguaje que te resulta desconocido, en mi opinión lo más lógico antes de preguntar cosas semejantes como las diferencias entre operadores o las comillas dobles, sería ojear la documentación básica del lenguaje para conocer esos operadores y saber como actuan, que eso es lo primero que se debe hacer ...como mínimo.

· Python Strings

· (Unofficial) Python Operators

Saludos!
7510  Foros Generales / Dudas Generales / Re: ¿Cual es el MimeType de un archivo '.reg'? (texto unicode) en: 6 Marzo 2014, 18:18 pm
Una aplicación que tengo dice que es esta.

application/octet-stream


Ok, gracias :)
Páginas: 1 ... 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 [751] 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 ... 1252
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines