Menú

Mostrar Mensajes

Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.

Mostrar Mensajes Menú

Mensajes - Eleкtro

#5331
Añádele el parámetro /R al FOR para habilitar la recursividad de archivos.

For /R %%# In () DO ()

Es algo muy básico, trata de buscar antes de preguntar:
For - Looping commands | Windows CMD | SS64.com
(ni siquiera debes buscar, tienes la documentación del FOR en la ayuda del comando, en consola: FOR /?)

Saludos
#5332
Una helper class para manejar los servicios de Windows.

Por el momento puede listar, iniciar, detener, y determinar el estado o el modo de inicio de un servicio.
(no lo he testeado mucho en profundidad)

Ejemplos de uso:
Código (vbnet) [Seleccionar]
        Dim svcName As String = "themes"
        Dim svcDisplayName As String = ServiceUtils.GetDisplayName(svcName)
        Dim svcStatus As ServiceControllerStatus = ServiceUtils.GetStatus(svcName)
        Dim svcStartMode As ServiceUtils.SvcStartMode = ServiceUtils.GetStartMode(svcName)

        ServiceUtils.SetStartMode(svcName, ServiceUtils.SvcStartMode.Automatic)
        ServiceUtils.SetStatus(svcName, ServiceUtils.SvcStatus.Stop, wait:=True, throwOnStatusMissmatch:=True)


Source code:
Código (vbnet) [Seleccionar]
' ***********************************************************************
' Author   : Elektro
' Modified : 14-April-2015
' ***********************************************************************
' <copyright file="ServiceUtils.vb" company="Elektro Studios">
'     Copyright (c) Elektro Studios. All rights reserved.
' </copyright>
' ***********************************************************************

#Region " Usage Examples "

'Dim svcName As String = "themes"
'Dim svcDisplayName As String = ServiceUtils.GetDisplayName(svcName)
'Dim svcStatus As ServiceControllerStatus = ServiceUtils.GetStatus(svcName)
'Dim svcStartMode As ServiceUtils.SvcStartMode = ServiceUtils.GetStartMode(svcName)

'ServiceUtils.SetStartMode(svcName, ServiceUtils.SvcStartMode.Automatic)
'ServiceUtils.SetStatus(svcName, ServiceUtils.SvcStatus.Stop, wait:=True, throwOnStatusMissmatch:=True)

#End Region

#Region " Option Statements "

Option Strict On
Option Explicit On
Option Infer Off

#End Region

#Region " Imports "

Imports Microsoft.Win32
Imports System.ServiceProcess

#End Region

''' <summary>
''' Contains related Windows service tools.
''' </summary>
Public NotInheritable Class ServiceUtils

#Region " Enumerations "

    ''' <summary>
    ''' Indicates the status of a service.
    ''' </summary>
    Public Enum SvcStatus

        ''' <summary>
        ''' The service is running.
        ''' </summary>
        Start

        ''' <summary>
        ''' The service is stopped.
        ''' </summary>
        [Stop]

    End Enum

    ''' <summary>
    ''' Indicates the start mode of a service.
    ''' </summary>
    Public Enum SvcStartMode As Integer

        ''' <summary>
        ''' Indicates that the service has not a start mode defined.
        ''' Since a service should have a start mode defined, this means an error occured retrieving the start mode.
        ''' </summary>
        Undefinied = 0

        ''' <summary>
        ''' Indicates that the service is to be started (or was started) by the operating system, at system start-up.
        ''' The service is started after other auto-start services are started plus a short delay.
        ''' </summary>
        AutomaticDelayed = 1

        ''' <summary>
        ''' Indicates that the service is to be started (or was started) by the operating system, at system start-up.
        ''' If an automatically started service depends on a manually started service,
        ''' the manually started service is also started automatically at system startup.
        ''' </summary>
        Automatic = 2 'ServiceStartMode.Automatic

        ''' <summary>
        ''' Indicates that the service is started only manually,
        ''' by a user (using the Service Control Manager) or by an application.
        ''' </summary>
        Manual = 3 'ServiceStartMode.Manual

        ''' <summary>
        ''' Indicates that the service is disabled, so that it cannot be started by a user or application.
        ''' </summary>
        Disabled = 4 ' ServiceStartMode.Disabled

    End Enum

#End Region

#Region " Public Methods "

    ''' <summary>
    ''' Retrieves all the services on the local computer, except for the device driver services.
    ''' </summary>
    ''' <returns>IEnumerable(Of ServiceController).</returns>
    Public Shared Function GetServices() As IEnumerable(Of ServiceController)

        Return ServiceController.GetServices.AsEnumerable

    End Function

    ''' <summary>
    ''' Gets the name of a service.
    ''' </summary>
    ''' <param name="svcDisplayName">The service's display name.</param>
    ''' <returns>The service name.</returns>
    ''' <exception cref="ArgumentException">Any service found with the specified display name.;svcDisplayName</exception>
    Public Shared Function GetName(ByVal svcDisplayName As String) As String

        Dim svc As ServiceController = (From service As ServiceController In ServiceController.GetServices()
                                        Where service.DisplayName.Equals(svcDisplayName, StringComparison.OrdinalIgnoreCase)
                                        ).FirstOrDefault

        If svc Is Nothing Then
            Throw New ArgumentException("Any service found with the specified display name.", "svcDisplayName")

        Else
            Using svc
                Return svc.ServiceName
            End Using

        End If

    End Function

    ''' <summary>
    ''' Gets the display name of a service.
    ''' </summary>
    ''' <param name="svcName">The service name.</param>
    ''' <returns>The service's display name.</returns>
    ''' <exception cref="ArgumentException">Any service found with the specified name.;svcName</exception>
    Public Shared Function GetDisplayName(ByVal svcName As String) As String

        Dim svc As ServiceController = (From service As ServiceController In ServiceController.GetServices()
                                        Where service.ServiceName.Equals(svcName, StringComparison.OrdinalIgnoreCase)
                                        ).FirstOrDefault

        If svc Is Nothing Then
            Throw New ArgumentException("Any service found with the specified name.", "svcName")

        Else
            Using svc
                Return svc.DisplayName
            End Using

        End If

    End Function

    ''' <summary>
    ''' Gets the status of a service.
    ''' </summary>
    ''' <param name="svcName">The service name.</param>
    ''' <returns>The service status.</returns>
    ''' <exception cref="ArgumentException">Any service found with the specified name.;svcName</exception>
    Public Shared Function GetStatus(ByVal svcName As String) As ServiceControllerStatus

        Dim svc As ServiceController =
            (From service As ServiceController In ServiceController.GetServices()
             Where service.ServiceName.Equals(svcName, StringComparison.OrdinalIgnoreCase)
            ).FirstOrDefault

        If svc Is Nothing Then
            Throw New ArgumentException("Any service found with the specified name.", "svcName")

        Else
            Using svc
                Return svc.Status
            End Using

        End If

    End Function

    ''' <summary>
    ''' Gets the start mode of a service.
    ''' </summary>
    ''' <param name="svcName">The service name.</param>
    ''' <returns>The service's start mode.</returns>
    ''' <exception cref="ArgumentException">Any service found with the specified name.</exception>
    ''' <exception cref="Exception">Registry value "Start" not found for service.</exception>
    ''' <exception cref="Exception">Registry value "DelayedAutoStart" not found for service.</exception>
    Public Shared Function GetStartMode(ByVal svcName As String) As SvcStartMode

        Dim reg As RegistryKey = Nothing
        Dim startModeValue As Integer = 0
        Dim delayedAutoStartValue As Integer = 0

        Try
            reg = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\" & svcName, writable:=False)

            If reg Is Nothing Then
                Throw New ArgumentException("Any service found with the specified name.", paramName:="svcName")

            Else
                startModeValue = Convert.ToInt32(reg.GetValue("Start", defaultValue:=-1))
                delayedAutoStartValue = Convert.ToInt32(reg.GetValue("DelayedAutoStart", defaultValue:=0))

                If startModeValue = -1 Then
                    Throw New Exception(String.Format("Registry value ""Start"" not found for service '{0}'.", svcName))
                    Return SvcStartMode.Undefinied

                Else
                    Return DirectCast([Enum].Parse(GetType(SvcStartMode),
                                                   (startModeValue - delayedAutoStartValue).ToString), SvcStartMode)

                End If

            End If

        Catch ex As Exception
            Throw

        Finally
            If reg IsNot Nothing Then
                reg.Dispose()
            End If

        End Try

    End Function

    ''' <summary>
    ''' Gets the start mode of a service.
    ''' </summary>
    ''' <param name="svc">The service.</param>
    ''' <returns>The service's start mode.</returns>
    Public Shared Function GetStartMode(ByVal svc As ServiceController) As SvcStartMode

        Return GetStartMode(svc.ServiceName)

    End Function

    ''' <summary>
    ''' Sets the start mode of a service.
    ''' </summary>
    ''' <param name="svcName">The service name.</param>
    ''' <param name="startMode">The start mode.</param>
    ''' <exception cref="ArgumentException">Any service found with the specified name.</exception>
    ''' <exception cref="ArgumentException">Unexpected value.</exception>
    Public Shared Sub SetStartMode(ByVal svcName As String,
                                   ByVal startMode As SvcStartMode)

        Dim reg As RegistryKey = Nothing

        Try
            reg = Registry.LocalMachine.OpenSubKey("SYSTEM\CurrentControlSet\Services\" & svcName, writable:=True)

            If reg Is Nothing Then
                Throw New ArgumentException("Any service found with the specified name.", paramName:="svcName")

            Else

                Select Case startMode

                    Case SvcStartMode.AutomaticDelayed
                        reg.SetValue("DelayedAutoStart", 1, RegistryValueKind.DWord)
                        reg.SetValue("Start", SvcStartMode.Automatic, RegistryValueKind.DWord)

                    Case SvcStartMode.Automatic, SvcStartMode.Manual, SvcStartMode.Disabled
                        reg.SetValue("DelayedAutoStart", 0, RegistryValueKind.DWord)
                        reg.SetValue("Start", startMode, RegistryValueKind.DWord)

                    Case Else
                        Throw New ArgumentException("Unexpected value.", paramName:="startMode")

                End Select

            End If

        Catch ex As Exception
            Throw

        Finally
            If reg IsNot Nothing Then
                reg.Dispose()
            End If

        End Try

    End Sub

    ''' <summary>
    ''' Sets the start mode of a service.
    ''' </summary>
    ''' <param name="svc">The service.</param>
    ''' <param name="startMode">The start mode.</param>
    Public Shared Sub SetStartMode(ByVal svc As ServiceController,
                                   ByVal startMode As SvcStartMode)

        SetStartMode(svc.ServiceName, startMode)

    End Sub

    ''' <summary>
    ''' Sets the status of a service.
    ''' </summary>
    ''' <param name="svcName">The service name.</param>
    ''' <param name="status">The desired service status.</param>
    ''' <param name="wait">if set to <c>true</c> waits for the status change completition.</param>
    ''' <param name="throwOnStatusMissmatch">
    ''' If set to <c>true</c> throws an error when attempting to start a service that is started,
    ''' or attempting to stop a service that is stopped.
    ''' </param>
    ''' <exception cref="ArgumentException">Any service found with the specified name.;svcName</exception>
    ''' <exception cref="ArgumentException">Cannot start service because it is disabled.</exception>
    ''' <exception cref="ArgumentException">Cannot start service because a dependant service is disabled.</exception>
    ''' <exception cref="ArgumentException">The service is already running or pendng to run it.</exception>
    ''' <exception cref="ArgumentException">The service is already stopped or pendng to stop it.</exception>
    ''' <exception cref="ArgumentException">Unexpected enumeration value.</exception>
    ''' <exception cref="Exception"></exception>
    Public Shared Sub SetStatus(ByVal svcName As String,
                                ByVal status As SvcStatus,
                                Optional wait As Boolean = False,
                                Optional ByVal throwOnStatusMissmatch As Boolean = False)

        Dim svc As ServiceController = Nothing

        Try
            svc = (From service As ServiceController In ServiceController.GetServices()
                   Where service.ServiceName.Equals(svcName, StringComparison.OrdinalIgnoreCase)
                  ).FirstOrDefault

            If svc Is Nothing Then
                Throw New ArgumentException("Any service found with the specified name.", "svcName")

            ElseIf GetStartMode(svc) = SvcStartMode.Disabled Then
                Throw New Exception(String.Format("Cannot start or stop service '{0}' because it is disabled.", svcName))

            Else

                Select Case status

                    Case SvcStatus.Start

                        Select Case svc.Status

                            Case ServiceControllerStatus.Stopped,
                                 ServiceControllerStatus.StopPending,
                                 ServiceControllerStatus.Paused,
                                 ServiceControllerStatus.PausePending

                                For Each dependantSvc As ServiceController In svc.ServicesDependedOn

                                    If GetStartMode(dependantSvc) = SvcStartMode.Disabled Then
                                        Throw New Exception(String.Format("Cannot start service '{0}' because a dependant service '{1}' is disabled.",
                                                                          svcName, dependantSvc.ServiceName))
                                        Exit Select
                                    End If

                                Next dependantSvc

                                svc.Start()
                                If wait Then
                                    svc.WaitForStatus(ServiceControllerStatus.Running)
                                End If

                            Case ServiceControllerStatus.Running,
                                 ServiceControllerStatus.StartPending,
                                 ServiceControllerStatus.ContinuePending

                                If throwOnStatusMissmatch Then
                                    Throw New Exception(String.Format("The service '{0}' is already running or pendng to run it.", svcName))
                                End If

                        End Select

                    Case SvcStatus.Stop

                        Select Case svc.Status

                            Case ServiceControllerStatus.Running,
                                 ServiceControllerStatus.StartPending,
                                 ServiceControllerStatus.ContinuePending

                                svc.Stop()
                                If wait Then
                                    svc.WaitForStatus(ServiceControllerStatus.Stopped)
                                End If

                            Case ServiceControllerStatus.Stopped,
                                 ServiceControllerStatus.StopPending,
                                 ServiceControllerStatus.Paused,
                                 ServiceControllerStatus.PausePending

                                If throwOnStatusMissmatch Then
                                    Throw New Exception(String.Format("The service '{0}' is already stopped or pendng to stop it.", svcName))
                                End If

                        End Select

                    Case Else
                        Throw New ArgumentException("Unexpected enumeration value.", paramName:="status")

                End Select

            End If

        Catch ex As Exception
            Throw

        Finally
            If svc IsNot Nothing Then
                svc.Close()
            End If

        End Try

    End Sub

#End Region

End Class
#5333
¿Soy el único que piensa que esto no tiene ningún sentido y estais llevando ya el tema hacia límites extremos?.

No se, pero por hacer una simple comparación, nunca he visto a alguien que por llamarle subnormal vaya y publique un post sobre el coeficiente intelectual de su ciudad o sobre psicología para intentar demostrar algo... xD. ¿se entiende, no?.

Saludos!
#5334
Microsoft tiene un foro de soporte dedicado para problemas con Hotmail (outlook.com), el cual por cierto a mi me ayudó en varias ocasiones para recuperar cuentas, cualquier moderador de allí te podrá intentar solucionar el conflicto con tu cuenta de correo siempre que te puedas identificar cómo el propietario de tal.

Soporte:
http://windows.microsoft.com/es-419/windows/contact-support

Soporte Outlook
http://answers.microsoft.com/es-es/outlook_com

Preguntar en el foro de Outlook:
http://answers.microsoft.com/es-es/newthread?forum=outlook_com&threadtype=Questions&cancelurl=%2Fes-es%2Foutlook_com

PD: La idea es que hagas una cuenta temporal con la que puedas publicar en el foro para exponer el problema que tienes con la cuenta que no recuerdas.

Saludos.
#5335
Muy poca información das.

Acude a la asistencia online del servicio de mail que tengas.

Para Gmail: https://support.google.com/dartsignin/answer/114766?hl=en




De todas formas, si has iniciado sesión a dicho servicio desde tu navegador y no has eliminado los rastros entonces revisa las cookies de esa página web de mail para intentar hallar el nombre de usuario
https://addons.mozilla.org/en-us/firefox/addon/cookies-manager-plus/

o, en caso de que también hayas guardado la contraseña al iniciar sesión entonces prueba a utilizar aplicaciones cómo Browser Password Decryptor para que te sea más sencillo de localizar:
http://securityxploded.com/browser-password-decryptor.php

Slaudos
#5336
Foro Libre / Re: ayuda para independizarme
13 Abril 2015, 09:05 AM
Cita de: http://foro.elhacker.net/papelera/como_pedir_un_prestamo_a_la_mafia-t384462.0.html;msg1833327#msg1833327hola mi nombre es Enrique y vivo con mi madre tengo 30 años de eda
bueno yo quiero independisame, estoy buscando prestamista por internet
y todo son legares bueno pues entoce e desidido pedirle un credito a la mafia
estoy pensando en ir a clubs de alterne a intenta da con la mafia pero no me atrevo balla que sea una mafia solo especialisada en mujeres y se cabreen
aver si arguien de foro me puede aurienta
, saludos.

.
..
...

#5337
Transformar una imagen a blanco y negro:

Código (vbnet) [Seleccionar]
    ''' <summary>
    ''' Transforms an image to black and white.
    ''' </summary>
    ''' <param name="img">The image.</param>
    ''' <returns>The black and white image.</returns>
    Public Shared Function GetBlackAndWhiteImage(ByVal img As Image) As Image

        Dim bmp As Bitmap = New Bitmap(img.Width, img.Height)

        Dim grayMatrix As New System.Drawing.Imaging.ColorMatrix(
            {
                New Single() {0.299F, 0.299F, 0.299F, 0, 0},
                New Single() {0.587F, 0.587F, 0.587F, 0, 0},
                New Single() {0.114F, 0.114F, 0.114F, 0, 0},
                New Single() {0, 0, 0, 1, 0},
                New Single() {0, 0, 0, 0, 1}
            })

        Using g As Graphics = Graphics.FromImage(bmp)

            Using ia As System.Drawing.Imaging.ImageAttributes = New System.Drawing.Imaging.ImageAttributes()

                ia.SetColorMatrix(grayMatrix)
                ia.SetThreshold(0.5)

                g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height,
                                                 GraphicsUnit.Pixel, ia)

            End Using

        End Using

        Return bmp

    End Function
#5338
Una simple función que publiqué en S.O para cifrar/descifrar un String mediante la técnica de Caesar.

Ejemplo de uso:
Código (vbnet) [Seleccionar]
       Dim value As String = "Hello World!"

       Dim encrypted As String = CaesarEncrypt(value, shift:=15)
       Dim decrypted As String = CaesarDecrypt(encrypted, shift:=15)

       Debug.WriteLine(String.Format("Unmodified string: {0}", value))
       Debug.WriteLine(String.Format("Encrypted  string: {0}", encrypted))
       Debug.WriteLine(String.Format("Decrypted  string: {0}", decrypted))


Source:
Código (vbnet) [Seleccionar]
   ''' <summary>
   ''' Encrypts a string using Caesar's substitution technique.
   ''' </summary>
   ''' <remarks> http://en.wikipedia.org/wiki/Caesar_cipher </remarks>
   ''' <param name="text">The text to encrypt.</param>
   ''' <param name="shift">The character shifting.</param>
   ''' <param name="charSet">A set of character to use in encoding.</param>
   ''' <returns>The encrypted string.</returns>
   Public Shared Function CaesarEncrypt(ByVal text As String,
                                        ByVal shift As Integer,
                                        Optional ByVal charSet As String =
                                                       "abcdefghijklmnopqrstuvwxyz" &
                                                       "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
                                                       "0123456789" &
                                                       "çñáéíóúàèìòùäëïöü" &
                                                       "ÇÑÁÉÍÓÚÀÈÌÒÙÄËÏÖÜ" &
                                                       " ,;.:-_´¨{`^[+*]ºª\!|""#$~%€&¬/()=?¿'¡}*") As String

       Dim sb As New System.Text.StringBuilder With {.Capacity = text.Length}

       For Each c As Char In text

           Dim charIndex As Integer = charSet.IndexOf(c)

           If charIndex = -1 Then
               Throw New ArgumentException(String.Format("Character '{0}' not found in character set '{1}'.", c, charSet), "charSet")

           Else
               Do Until (charIndex + shift) < (charSet.Length)
                   charIndex -= charSet.Length
               Loop

               sb.Append(charSet(charIndex + shift))

           End If

       Next c

       Return sb.ToString

   End Function

   ''' <summary>
   ''' Decrypts a string using Caesar's substitution technique.
   ''' </summary>
   ''' <remarks> http://en.wikipedia.org/wiki/Caesar_cipher </remarks>
   ''' <param name="text">The encrypted text to decrypt.</param>
   ''' <param name="shift">The character shifting to reverse the encryption.</param>
   ''' <param name="charSet">A set of character to use in decoding.</param>
   ''' <returns>The decrypted string.</returns>
   Public Shared Function CaesarDecrypt(ByVal text As String,
                                        ByVal shift As Integer,
                                        Optional ByVal charSet As String =
                                                       "abcdefghijklmnopqrstuvwxyz" &
                                                       "ABCDEFGHIJKLMNOPQRSTUVWXYZ" &
                                                       "0123456789" &
                                                       "çñáéíóúàèìòùäëïöü" &
                                                       "ÇÑÁÉÍÓÚÀÈÌÒÙÄËÏÖÜ" &
                                                       " ,;.:-_´¨{`^[+*]ºª\!|""#$~%€&¬/()=?¿'¡}*") As String

       Return CaesarEncrypt(text, shift, String.Join("", charSet.Reverse))

   End Function
#5339
Citar# -*- coding: Windows-1252 -*-
# -*- coding: cp1252 -*-

Si pongo sólo la segunda o la tercera línea funciona en el IDE de Python pero no en los otros dos.

1. Ambas "lineas" o codificaciones son la misma, el código de página o Codepage 1252 hace referencia al la misma codificación del alfabeto latino al que hace referencia Windows-1252, ya que son solo dos formas de referirse a lo mismo.

2. La codificación interna de la consola tiene un papel muy importante, para que puedas visualizar correctamente los caracteres latinos primero debes estar usando el código de página o codepage 850 (que es lo mismo que decir cp850 o IBM 850), guardar el archivo de tu script en codificación ANSI (windows-1252), declarar la codificación mostrar el string unicode y listo:

Código (python) [Seleccionar]
# -*- coding: Windows-1252 -*-

import sys
print sys.stdout.encoding

print u"áéíóú àèìòù Ñ"


PD: el codepage de la CMD lo puedes modificar con el comando CHCP.

Saludos
#5340
Ingeniería Inversa / Re: editor de procesos
11 Abril 2015, 06:14 AM
¿En serio estás preguntando cómo renombrar un archivo?.

...¿O te refieres a otra cosa?.