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


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


  Mostrar Mensajes
Páginas: 1 ... 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 [551] 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 ... 1253
5501  Programación / Python / Re: [Python]Duda con thread en: 11 Mayo 2015, 10:40 am
Mi pregunta sería: ¿Cómo puedo manejar una excepción dentro de MathWorker sin estropear la idea principal (se realizan cuatro tareas pero que todas terminen)?

Si estás controlando correctamente la excepción entonces no se debería detener la ejecución del thread.

Creo que vas a tener que mostrar lo que tengas escrito en el bloque del except:, y el tipo de excepción que te lanza.

Recuerda que siempre puedes utilizar la declaración pass para ignorar la excepción:

Código
  1. ...
  2. for value in queue.get():
  3.    try:
  4.        0 + str(value)
  5.    except BaseException as e:
  6.        # print e.message, e.args
  7.        pass
  8. queue.task_done()
  9. ...

saludos
5502  Foros Generales / Foro Libre / Re: ¿Está la NASA creando una nave que viaja más rápido que la luz? en: 11 Mayo 2015, 10:06 am
jajajjaa, a la Luna en 4 horas, ajajjajajaaaj

En fin, otra chorrada estúpida de la NASA para mantenerles entretenidos sin que piensen ni se cuestionen en lo que realmente deberian estar pensando de ellos... en fin, son unos expertos en juegos psicológicos y manipulación subliminal.

De España a Nueva York hay solamente 5.778 kilómetros y ya se tarda 7 horas en aviones con tecnología punta (http://www.howmanyhours.com/distance/spain/new-york.php) ...y si a esto le añadiesemos la propulsion espacial punta se seguiría traduciendo en un tiempo más que cuestionable, pero claro, NASA y sus "próximos" planes de última generación con super inventos electronmágneticos y blah blah blah van a ser capaces de recorrer la distancia de La Tierra a La Luna, es decir, unos 384.403 Kilómetros, en 4 horitas, si señor ...¿qué duda cabe?.

A todo esto cabe mencionar que el tiempo record que ha tardado NASA en viajar desde La Tierra hasta La Luna han sido 8 horas, en la missión New Horizons: Pluto, pero obviamente esto fue sin tripulación, es decir, en un artefacto de menor dimensión y donde no importaba el impacto de la fuerza G de aceleración/velocidad, en unas pre-condiciones de laboratorio, y lo más importante de todo, sin desaceleración.

NASA ha perdido el Norte desde hace mucho, sueltan una gilipollez tras otra, que si construir una ciudad flotante en las nubes tóxicas de Venus, que si taladrar el hielo de Europe de un lado a otro, que si viajar de un planeta a otro en 4 horas... yo creo que tienen por ahí escondido alguna plantación desconocida de drogas marcianas que les está afectando demasiado a las neuronas.

NO SE DEJEN ENGAÑAR.

Saludos.
5503  Programación / .NET (C#, VB.NET, ASP) / Re: como borrar el valor del element anterior cuando selecciono con el SelectedValue en: 11 Mayo 2015, 09:37 am
Si estás utilizando un ComboBox estático (ComboBox.DropDownStyle = DropDownList) entonces utiliza sin miedo la propiedad ComboBox.Text, en lugar de ComboBox.SelectedValue.

Saludos
5504  Programación / Scripting / Re: ayuda crear consola batch sin que se cierre al llegar al ultimo comando en: 11 Mayo 2015, 09:29 am
1. Esto es muy incorrecto:
Citar
Código
  1. if -%1-==-- (goto regular) else (goto noregular)

Para prevenir un argumento vacio, lo expandes para eliminarle comillas dobles, y le añades tú las comillas dobles:
Código
  1. if "%~1" EQU "" (goto :regular) else (goto :noregular)

2. El código que mostraste, en mi caso si que termina la ejecución del script de la forma que deseas ...volviendo al script que lo invocó, así que no puedo reproducir el error de diseño que comentas, pero de todas formas corregí algunas pequeñas cosas para seguir buenas prácticas de uso, prueba así:
Código
  1. @echo off
  2. color 0a
  3.  
  4. :: Argument Handling.
  5. If "%~1" EQU "" (
  6. goto :regular
  7. ) else (
  8. goto :noregular
  9. )
  10.  
  11. :NoRegular
  12. If /i "%~x1" EQU ".ico" (
  13. GoTo :ico
  14. )
  15.  
  16. If /i "%~x1" EQU ".bmp" (
  17. GoTo :bmp
  18. )
  19.  
  20. Echo: el formato de la imagen no es aceptable use ico para el icono o bmp para el logo.
  21. Echo: asegurese de no incluir coma , en el nombre de la imagen puede causar este mensaje.
  22. Exit /B 1
  23.  
  24. :Regular
  25. Set /p "archivo= arrastra el icono o el logo y sueltelo aqui luego presione enter:"
  26.  
  27. Set "esau=%archivo:"=-%" & REM "
  28. If /I "%esau:~-5%" EQU ".bmp-" (GoTo :bmp)
  29. If /I "%esau:~-4%" EQU ".bmp"  (GoTo :bmp)
  30. If /I "%esau:~-5%" EQU ".ico-" (GoTo :ico)
  31. If /I "%esau:~-4%" EQU ".ico"  (GoTo :ico)
  32.  
  33. CLS
  34. Echo: el formato de la imagen no es aceptable use ico para el icono o bmp para el logo
  35. Exit /B 1
  36.  
  37. :ico
  38. Echo icono
  39. Pause&Exit /B 0
  40.  
  41. :bmp
  42. Echo logo
  43. Pause&Exit /B 0

Saludos
5505  Media / Multimedia / Re: duda sobre los formatos en: 10 Mayo 2015, 19:01 pm
Cita de: perez_bcn
¿hay alguna lista de formatos de sonido?

Google es el motor de búsqueda de contenido en Internet más utilizado, de la empresa multinacional estadounidense Google Inc.

Cita de: perez_bcn
¿se pueden creer nuevos formatos?

¿Que fue antes, el MP2, o el MP3?, alguno tuvo que ser primero, y el otro después.

Cita de: perez_bcn
¿los formatos de video y de imagen son lo mismo?

Wikipedia es una enciclopedia libre, políglota y editada colaborativamente, es administrada por la Fundación Wikimedia, una organización sin ánimo de lucro.
5506  Programación / .NET (C#, VB.NET, ASP) / Re: Librería de Snippets !! (Compartan aquí sus snippets) en: 10 Mayo 2015, 17:08 pm
PathUtil, una class para administrar los directorios de la variable de entorno PATH, y las extensiones de la variable de entorno PATHEXT.

( IMPORTANTE: Esta class depende de mi otra Class RegEdit, que pueden descargar aquí: http://foro.elhacker.net/net/libreria_de_snippets_compartan_aqui_sus_snippets-t378770.0.html;msg2003658#msg2003658 )



Código
  1. ' ***********************************************************************
  2. ' Author   : Elektro
  3. ' Modified : 09-April-2015
  4. ' ***********************************************************************
  5. ' <copyright file="PathUtil.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Option Statements "
  11.  
  12. Option Explicit On
  13. Option Strict On
  14. Option Infer Off
  15.  
  16. #End Region
  17.  
  18. #Region " Path Util "
  19.  
  20. Namespace Tools
  21.  
  22.    ''' <summary>
  23.    ''' Contains related PATH and PATHEXT registry tools.
  24.    ''' </summary>
  25.    Public NotInheritable Class PathUtil
  26.  
  27. #Region " Properties "
  28.  
  29.        ''' <summary>
  30.        ''' Gets the registry path of the Environment subkey for the current user.
  31.        ''' </summary>
  32.        ''' <value>The registry path of the Environment subkey for the current user.</value>
  33.        Public Shared ReadOnly Property EnvironmentPathCurrentUser As String
  34.            Get
  35.                Return "HKEY_CURRENT_USER\Environment"
  36.            End Get
  37.        End Property
  38.  
  39.        ''' <summary>
  40.        ''' Gets the registry path of the Environment subkey for all users.
  41.        ''' </summary>
  42.        ''' <value>The registry path of the Environment subkey for all users.</value>
  43.        Public Shared ReadOnly Property EnvironmentPathAllUsers As String
  44.            Get
  45.                Return "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
  46.            End Get
  47.        End Property
  48.  
  49.        ''' <summary>
  50.        ''' Gets the default data of the PATH registry value of a 32-Bit Windows.
  51.        ''' </summary>
  52.        ''' <value>The default data of the PATH registry value of a 32-Bit Windows.</value>
  53.        Public Shared ReadOnly Property DefaultPathDataWin32 As String
  54.            Get
  55.                Return "C:\Windows;C:\Windows\System32;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0"
  56.            End Get
  57.        End Property
  58.  
  59.        ''' <summary>
  60.        ''' Gets the default data of the PATH registry value of a 64-Bit Windows.
  61.        ''' </summary>
  62.        ''' <value>The default data of the PATH registry value of a 64-Bit Windows.</value>
  63.        Public Shared ReadOnly Property DefaultPathDataWin64 As String
  64.            Get
  65.                Return "C:\Windows;C:\Windows\System32;C:\Windows\System32\Wbem;C:\Windows\SysWOW64;C:\Windows\System32\WindowsPowerShell\v1.0"
  66.            End Get
  67.        End Property
  68.  
  69.        ''' <summary>
  70.        ''' Gets the default data of the PATHEXt registry value.
  71.        ''' </summary>
  72.        ''' <value>The default data of the PATHEXt registry value.</value>
  73.        Public Shared ReadOnly Property DefaultPathExtData As String
  74.            Get
  75.                Return ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE"
  76.            End Get
  77.        End Property
  78.  
  79.        ''' <summary>
  80.        ''' Gets the registry export string format.
  81.        ''' </summary>
  82.        ''' <value>The registry export string format.</value>
  83.        Private Shared ReadOnly Property ExportStringFormat As String
  84.            Get
  85.                Return "Windows Registry Editor Version 5.00{0}{0}" &
  86.                       "[HKEY_CURRENT_USER\Environment]{0}" &
  87.                       """PATH""=""{1}""{0}" &
  88.                       """PATHEXT""=""{2}""{0}{0}" &
  89.                       "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]{0}" &
  90.                       """PATH""=""{3}""{0}" &
  91.                       """PATHEXT""=""{4}"""
  92.            End Get
  93.        End Property
  94.  
  95. #End Region
  96.  
  97. #Region " Enumerations "
  98.  
  99.        ''' <summary>
  100.        ''' Specifies the registry user mode.
  101.        ''' </summary>
  102.        Public Enum UserMode
  103.  
  104.            ''' <summary>
  105.            ''' The current user (HKCU).
  106.            ''' </summary>
  107.            Current = 0
  108.  
  109.            ''' <summary>
  110.            ''' All users (HKLM).
  111.            ''' </summary>
  112.            AllUsers = 1
  113.  
  114.        End Enum
  115.  
  116. #End Region
  117.  
  118. #Region " Constructors "
  119.  
  120.        ''' <summary>
  121.        ''' Prevents a default instance of the <see cref="PathUtil"/> class from being created.
  122.        ''' </summary>
  123.        Private Sub New()
  124.        End Sub
  125.  
  126. #End Region
  127.  
  128. #Region " Public Methods "
  129.  
  130.        ''' <summary>
  131.        ''' Gets the default data of the PATH value for the registry of the specified user (as String).
  132.        ''' </summary>
  133.        ''' <returns>The default data of the PATH value for the registry of the specified user.</returns>
  134.        Public Shared Function GetDefaultPathDataString() As String
  135.  
  136.            If Not Environment.Is64BitOperatingSystem Then
  137.                Return DefaultPathDataWin32
  138.            Else
  139.                Return DefaultPathDataWin64
  140.            End If
  141.  
  142.        End Function
  143.  
  144.        ''' <summary>
  145.        ''' Gets the default data of the PATH value for the registry of the specified user (as Enumerable).
  146.        ''' </summary>
  147.        ''' <returns>The default data of the PATH value for the registry of the specified user.</returns>
  148.        Public Shared Function GetDefaultPathDataList() As IEnumerable(Of String)
  149.  
  150.            If Not Environment.Is64BitOperatingSystem Then
  151.                Return DefaultPathDataWin32.Split({";"c}, StringSplitOptions.RemoveEmptyEntries)
  152.            Else
  153.                Return DefaultPathDataWin64.Split({";"c}, StringSplitOptions.RemoveEmptyEntries)
  154.            End If
  155.  
  156.        End Function
  157.  
  158.        ''' <summary>
  159.        ''' Gets the data of the PATH value on the registry of the specified user (as String).
  160.        ''' </summary>
  161.        ''' <param name="userMode">The user mode.</param>
  162.        ''' <returns>The data of the PATH value on the registry of the specified user.</returns>
  163.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  164.        Public Shared Function GetPathDataString(ByVal userMode As UserMode) As String
  165.  
  166.            Select Case userMode
  167.  
  168.                Case PathUtil.UserMode.Current
  169.                    Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH")
  170.  
  171.                Case PathUtil.UserMode.AllUsers
  172.                    Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH")
  173.  
  174.                Case Else
  175.                    Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  176.  
  177.            End Select
  178.  
  179.        End Function
  180.  
  181.        ''' <summary>
  182.        ''' Gets the data of the PATH value on the registry of the specified user (as Enumerable).
  183.        ''' </summary>
  184.        ''' <param name="userMode">The user mode.</param>
  185.        ''' <returns>The data of the PATH value on the registry of the specified user.</returns>
  186.        Public Shared Function GetPathDataList(ByVal userMode As UserMode) As IEnumerable(Of String)
  187.  
  188.            Return GetPathDataString(userMode).Split({";"c}, StringSplitOptions.RemoveEmptyEntries)
  189.  
  190.        End Function
  191.  
  192.        ''' <summary>
  193.        ''' Gets the data of the PATHEXT value on the registry of the specified user (as String).
  194.        ''' </summary>
  195.        ''' <param name="userMode">The user mode.</param>
  196.        ''' <returns>The data of the PATHEXT value on the registry of the specified user.</returns>
  197.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  198.        Public Shared Function GetPathExtDataString(ByVal userMode As UserMode) As String
  199.  
  200.            Select Case userMode
  201.  
  202.                Case PathUtil.UserMode.Current
  203.                    Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT")
  204.  
  205.                Case PathUtil.UserMode.AllUsers
  206.                    Return RegEdit.GetValueData(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT")
  207.  
  208.                Case Else
  209.                    Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  210.  
  211.            End Select
  212.  
  213.        End Function
  214.  
  215.        ''' <summary>
  216.        ''' Gets data of the data of the PATHEXT value on the registry of the specified user (as Enumerable).
  217.        ''' </summary>
  218.        ''' <param name="userMode">The user mode.</param>
  219.        ''' <returns>The data of the PATHEXT value on the registry of the specified user.</returns>
  220.        Public Shared Function GetPathExtDataList(ByVal userMode As UserMode) As IEnumerable(Of String)
  221.  
  222.            Return GetPathExtDataString(userMode).Split({";"c}, StringSplitOptions.RemoveEmptyEntries)
  223.  
  224.        End Function
  225.  
  226.        ''' <summary>
  227.        ''' Determines whether the PATH value exists on the registry of the specified user.
  228.        ''' </summary>
  229.        ''' <param name="userMode">The user mode.</param>
  230.        ''' <returns><c>true</c> if PATH value exists, <c>false</c> otherwise.</returns>
  231.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  232.        Public Shared Function PathExists(ByVal userMode As UserMode) As Boolean
  233.  
  234.            Select Case userMode
  235.  
  236.                Case PathUtil.UserMode.Current
  237.                    Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH")
  238.  
  239.                Case PathUtil.UserMode.AllUsers
  240.                    Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH")
  241.  
  242.                Case Else
  243.                    Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  244.  
  245.            End Select
  246.  
  247.        End Function
  248.  
  249.        ''' <summary>
  250.        ''' Determines whether the PATHEXT value exists on the registry of the specified user.
  251.        ''' </summary>
  252.        ''' <param name="userMode">The user mode.</param>
  253.        ''' <returns><c>true</c> if PATHEXT value exists, <c>false</c> otherwise.</returns>
  254.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  255.        Public Shared Function PathExtExists(ByVal userMode As UserMode) As Boolean
  256.  
  257.            Select Case userMode
  258.  
  259.                Case PathUtil.UserMode.Current
  260.                    Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT")
  261.  
  262.                Case PathUtil.UserMode.AllUsers
  263.                    Return RegEdit.ExistValue(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT")
  264.  
  265.                Case Else
  266.                    Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  267.  
  268.            End Select
  269.  
  270.        End Function
  271.  
  272.        ''' <summary>
  273.        ''' Exports the PATH and PATHEXT values to a target registry file.
  274.        ''' </summary>
  275.        ''' <param name="filepath">The filepath.</param>
  276.        ''' <exception cref="Exception"></exception>
  277.        Public Shared Sub Export(ByVal filepath As String)
  278.  
  279.            Try
  280.                IO.File.WriteAllText(filepath,
  281.                                     String.Format(ExportStringFormat,
  282.                                                   Environment.NewLine,
  283.                                                   GetPathDataString(UserMode.Current),
  284.                                                   GetPathExtDataString(UserMode.Current),
  285.                                                   GetPathDataString(UserMode.AllUsers),
  286.                                                   GetPathExtDataString(UserMode.AllUsers)),
  287.                                     encoding:=System.Text.Encoding.Unicode)
  288.  
  289.            Catch ex As Exception
  290.                Throw
  291.  
  292.            End Try
  293.  
  294.        End Sub
  295.  
  296.        ''' <summary>
  297.        ''' Creates a PATH value on the registry of the specified user and optionally fills the value with the specified data.
  298.        ''' </summary>
  299.        ''' <param name="userMode">The user mode.</param>
  300.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  301.        Public Shared Sub CreatePath(ByVal userMode As UserMode,
  302.                                     Optional data As String = "")
  303.  
  304.            Try
  305.                Select Case userMode
  306.  
  307.                    Case PathUtil.UserMode.Current
  308.                        RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH", valueData:=data)
  309.  
  310.                    Case PathUtil.UserMode.AllUsers
  311.                        RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH", valueData:=data)
  312.  
  313.                    Case Else
  314.                        Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  315.  
  316.                End Select
  317.  
  318.            Catch ex As Exception
  319.                Throw
  320.  
  321.            End Try
  322.  
  323.        End Sub
  324.  
  325.        ''' <summary>
  326.        ''' Creates a PATHEXT value on the registry of the specified user and optionally fills the value with the specified data..
  327.        ''' </summary>
  328.        ''' <param name="userMode">The user mode.</param>
  329.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  330.        Public Shared Sub CreatePathExt(ByVal userMode As UserMode,
  331.                                        Optional data As String = "")
  332.  
  333.            Try
  334.                Select Case userMode
  335.  
  336.                    Case PathUtil.UserMode.Current
  337.                        RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT", valueData:=data)
  338.  
  339.                    Case PathUtil.UserMode.AllUsers
  340.                        RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT", valueData:=data)
  341.  
  342.                    Case Else
  343.                        Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  344.  
  345.                End Select
  346.  
  347.            Catch ex As Exception
  348.                Throw
  349.  
  350.            End Try
  351.  
  352.        End Sub
  353.  
  354.        ''' <summary>
  355.        ''' Adds a directory into the PATH registry value of the specified user.
  356.        ''' </summary>
  357.        ''' <param name="userMode">The user mode.</param>
  358.        ''' <param name="directory">The directory path.</param>
  359.        ''' <exception cref="ArgumentException">Directory contains invalid character(s).;directory</exception>
  360.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  361.        Public Shared Sub AddDirectory(ByVal userMode As UserMode,
  362.                                       ByVal directory As String)
  363.  
  364.            If directory.Any(Function(c As Char) IO.Path.GetInvalidPathChars.Contains(c)) Then
  365.                Throw New ArgumentException(message:="Directory contains invalid character(s).", paramName:="directory")
  366.  
  367.            Else
  368.  
  369.                Select Case userMode
  370.  
  371.                    Case PathUtil.UserMode.Current
  372.                        RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATH",
  373.                                                       valueData:=String.Join(";"c, GetPathDataList(userMode).Concat({directory}).Distinct).Trim(";"c))
  374.  
  375.                    Case PathUtil.UserMode.AllUsers
  376.                        RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATH",
  377.                                                       valueData:=String.Join(";"c, GetPathDataList(userMode).Concat({directory}).Distinct).Trim(";"c))
  378.  
  379.                    Case Else
  380.                        Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  381.  
  382.                End Select
  383.  
  384.            End If
  385.  
  386.        End Sub
  387.  
  388.        ''' <summary>
  389.        ''' Adds a file extension into the PATHEXT registry value of the specified user.
  390.        ''' </summary>
  391.        ''' <param name="userMode">The user mode.</param>
  392.        ''' <param name="extension">The file extension.</param>
  393.        ''' <exception cref="ArgumentException">Unexpected enumeration value.;userMode</exception>
  394.        Public Shared Sub AddExtension(ByVal userMode As UserMode,
  395.                                       ByVal extension As String)
  396.  
  397.            If Not extension.StartsWith("."c) Then ' Fix extension.
  398.                extension.Insert(0, "."c)
  399.            End If
  400.  
  401.            Select Case userMode
  402.  
  403.                Case PathUtil.UserMode.Current
  404.                    RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathCurrentUser, valueName:="PATHEXT",
  405.                                                   valueData:=String.Join(";"c, GetPathExtDataList(userMode).Concat({extension})).Trim(";"c))
  406.  
  407.                Case PathUtil.UserMode.AllUsers
  408.                    RegEdit.CreateValue(Of String)(fullKeyPath:=EnvironmentPathAllUsers, valueName:="PATHEXT",
  409.                                                   valueData:=String.Join(";"c, GetPathExtDataList(userMode).Concat({extension})).Trim(";"c))
  410.  
  411.                Case Else
  412.                    Throw New ArgumentException(message:="Unexpected enumeration value.", paramName:="userMode")
  413.  
  414.            End Select
  415.  
  416.        End Sub
  417.  
  418.        ''' <summary>
  419.        ''' Deletes a directory from the PATH registry value of the specified user.
  420.        ''' </summary>
  421.        ''' <param name="userMode">The user mode.</param>
  422.        ''' <param name="directory">The directory path.</param>
  423.        Public Shared Sub DeleteDirectory(ByVal userMode As UserMode,
  424.                                          ByVal directory As String)
  425.  
  426.            Dim dirs As IEnumerable(Of String) =
  427.                From dir As String In GetPathDataList(userMode)
  428.                Where Not dir.ToLower.Equals(directory, StringComparison.OrdinalIgnoreCase)
  429.  
  430.            CreatePath(userMode, data:=String.Join(";"c, dirs))
  431.  
  432.        End Sub
  433.  
  434.        ''' <summary>
  435.        ''' Deletes a directory from the PATH registry value of the specified user.
  436.        ''' </summary>
  437.        ''' <param name="userMode">The user mode.</param>
  438.        ''' <param name="index">The directory index, 0 = First.</param>
  439.        ''' <exception cref="IndexOutOfRangeException">Directory index is out of range.</exception>
  440.        Public Shared Sub DeleteDirectory(ByVal userMode As UserMode,
  441.                                          ByVal index As Integer)
  442.  
  443.            Dim dirs As List(Of String) = GetPathDataList(userMode).ToList
  444.  
  445.            If (dirs.Count > index) Then
  446.                dirs.RemoveAt(index)
  447.            Else
  448.                Throw New IndexOutOfRangeException(Message:="Directory index is out of range.")
  449.            End If
  450.  
  451.            CreatePath(userMode, data:=String.Join(";"c, dirs))
  452.  
  453.        End Sub
  454.  
  455.        ''' <summary>
  456.        ''' Deletes a file extension from the PATHEXT registry value of the specified user.
  457.        ''' </summary>
  458.        ''' <param name="userMode">The user mode.</param>
  459.        ''' <param name="extension">The file extension.</param>
  460.        Public Shared Sub DeleteExtension(ByVal userMode As UserMode,
  461.                                          ByVal extension As String)
  462.  
  463.            If Not extension.StartsWith("."c) Then ' Fix extension.
  464.                extension.Insert(0, "."c)
  465.            End If
  466.  
  467.            Dim exts As IEnumerable(Of String) =
  468.                From ext As String In GetPathExtDataList(userMode)
  469.                Where Not ext.ToLower.Equals(extension, StringComparison.OrdinalIgnoreCase)
  470.  
  471.            CreatePath(userMode, data:=String.Join(";"c, exts))
  472.  
  473.        End Sub
  474.  
  475.        ''' <summary>
  476.        ''' Deletes a file extension from the PATHEXT registry value of the specified user.
  477.        ''' </summary>
  478.        ''' <param name="userMode">The user mode.</param>
  479.        ''' <param name="index">The file extension index, 0 = First.</param>
  480.        ''' <exception cref="IndexOutOfRangeException">File extension index is out of range.</exception>
  481.        Public Shared Sub DeleteExtension(ByVal userMode As UserMode,
  482.                                          ByVal index As Integer)
  483.  
  484.            Dim exts As List(Of String) = GetPathExtDataList(userMode).ToList
  485.  
  486.            If (exts.Count > index) Then
  487.                exts.RemoveAt(index)
  488.            Else
  489.                Throw New IndexOutOfRangeException(Message:="File extension index is out of range.")
  490.            End If
  491.  
  492.            CreatePathExt(userMode, data:=String.Join(";"c, exts))
  493.  
  494.        End Sub
  495.  
  496.        ''' <summary>
  497.        ''' Determines whether the PATH registry value of the specified user contains a directory.
  498.        ''' </summary>
  499.        ''' <param name="usermode">The usermode.</param>
  500.        ''' <param name="directory">The directory path.</param>
  501.        ''' <returns><c>true</c> if contains the specified directory; <c>false</c> otherwise.</returns>
  502.        Public Shared Function ContainsDirectory(ByVal usermode As UserMode,
  503.                                                 ByVal directory As String) As Boolean
  504.  
  505.            Return GetPathDataList(usermode).Any(Function(dir As String) dir.Equals(directory, StringComparison.OrdinalIgnoreCase))
  506.  
  507.        End Function
  508.  
  509.        ''' <summary>
  510.        ''' Determines whether the PATHEXT registry value of the specified user contains a directory.
  511.        ''' </summary>
  512.        ''' <param name="usermode">The usermode.</param>
  513.        ''' <param name="extension">The file extension.</param>
  514.        ''' <returns><c>true</c> if contains the specified file extension; <c>false</c> otherwise.</returns>
  515.        Public Shared Function ContainsExtension(ByVal usermode As UserMode,
  516.                                                 ByVal extension As String) As Boolean
  517.  
  518.            If Not extension.StartsWith("."c) Then ' Fix extension.
  519.                extension.Insert(0, "."c)
  520.            End If
  521.  
  522.            Return GetPathExtDataList(usermode).Any(Function(ext As String) ext.Equals(extension, StringComparison.OrdinalIgnoreCase))
  523.  
  524.        End Function
  525.  
  526. #End Region
  527.  
  528.    End Class
  529.  
  530. End Namespace
  531.  
  532. #End Region
  533.  
5507  Programación / Scripting / Re: Ayuda crear carpetas en ruta C: Usuarios Windows7 en: 10 Mayo 2015, 16:40 pm
1. Está prohibido duplicar temas, puedes utilizar el botón "Modificar".
2. Es obligatorio utilizar las etiquetas GeShi al publicar código.
Lee y respeta las normas del foro y del foro de programación/scripting, se debe seguir unas normas de publicación por el bien de todos.




Citar
Código
  1. rem*** Esto crea la carpeta "Magic Hills"
  2. md  "c:\Usuarios\JMR\AppData\Local\Magic Hills"
  3.  
  4. rem*** Esto crea la carpeta "Amazing Carousel"
  5. md  "c:\Usuarios\JMR\AppData\Local\Magic Hills\Amazing Carousel"
  6.  
  7. rem*** Esto crea la carpeta "profile"
  8. md  "c:\Usuarios\JMR\AppData\Local\Magic Hills\Amazing Carousel\profile"

Puedes simplificar todo eso creando las 3 carpetas al mismo tiempo:
Código
  1. MKDir "%LOCALAPPDATA%\Magic Hills\Amazing Carousel\Profile"


Sobre los errores que tienes, fíjate bien en lo que haces aquí:
Citar
Código
  1. copy "App\license.xml" "%LOCALAPPDATA%\Users\JMR\AppData\Local\Magic Hills\Amazing Carousel\profile"

Escribe en consola:
Código
  1. Echo "%LOCALAPPDATA%\Users\JMR\AppData\Local\Magic Hills\Amazing Carousel\profile"

Estás utilizando la variable de entorno dinámica %LocalAppData% que ya hace referencia a esa ruta, y le estás añadiendo la misma ruta...
Supongo que dicho esto, te habrás dado cuenta de cómo solucionarlo.

Sobre lo de que no te copia el archivo, probablemente sea por que no estás delimitando la carpeta, para solucionarlo, añádele un backslash al final de la ruta ("...\Profile\"), también puedes especificar directamente el nombre del archivo de destino (...\Profile\License.xml).

Saludos!
5508  Programación / .NET (C#, VB.NET, ASP) / Re: Evitar datos duplicados en listview en: 10 Mayo 2015, 11:54 am
Parezco retrasado, estoy viendo todo el rato que publicas código en VB.Net pero yo tenía metido en la cabeza que solo manejabas C# por que te confundí con otro usuario y por eso te puse el código en C# aunque solo veia Vb.Net, no era por "presumir" ni nada parecido jaja, el código en C# la verdad es que quedó de más.



investigare es el .trim

La función Trim, TrimStart y TrimEnd lo que hacen es eliminar los espacios del principio o del final de un String, pero puedes utilizar sus overloads para especificar otros (uno, o varios) caracteres a eliminar.

En el ejemplo de arriba yo solo utilizo Trim cómo modo preventivo por si a lo mejor en tu aplicación te estaba fallando por que escribias algún espacio al principio o al final.



Código
  1. 'Dim cantidad As String = Convert.ToInt32(rseCantidadPedido.Text).ToString("00")

Gracias le da un mejor formato a la cantidad vere si no me causa problema en la BD ya que si no me equivoco lo manda como string.

Si quieres enviarlo a la DataBase como valor de tipo Integer entonces solo tienes que convertir el string formateado:
Código
  1. Dim value as Integer = CInt("05")
o también:
Código
  1. Dim value as Integer = Convert.ToInt32("05")

Saludos
5509  Foros Generales / Sugerencias y dudas sobre el Foro / Re: ¿Por qué no se puede borrar temas o mensajes? en: 10 Mayo 2015, 11:35 am
¿Por qué no se puede borrar temas o mensajes?

La eliminación de un post es un derecho que queda reservado al Staff de moderadores y colaboradores.

El admin, co-admines, y moderadores globales pueden hacer lo que les plazca con los temas, los moderadores de sección pueden hacer lo que les plazca con los temas de la sección que moderan, y los colaboradores pueden eliminar/bloquear sus propios temas/comentarios.

Supongo que el motivo de que un usuario sin privilegios no pueda eliminar su propio tema/comentario debe ser evidentemente por dos cosas, por ética y por motivos de seguridad,
si un usuario formula una pregunta y se la resuelve, y luego ese usuario elimina el post entonces eso tiene cero ética, por que ese post ya no le sirve a nadie en busca de información,
o si un usuario publica un post y comienza una discusión fuerte con insultos y demás, y luego borra su tema para "no dejar huellas" de lo sucedido,
además, tengo entendido que los posts de las secciones públicas se indexan en Google y eso sería otro motivo por el que no creo que fuese beneficioso que cualquiera pueda eliminar su post.

Los moderadores estamos también para ayudar a los usuarios a resolver conflictos en sus posts, puedes comunicar el problema que tengas usando el botón "Reportar al moderador" que encontrarás en el tema, el reporte le llegará al moderador de esa sección,
pero obviamente si solo pretendes eliminar tus posts por que te da verguenza parecer un lammer... mejor ni lo intentes, por que eso es una tontería.



La verdad es que tengo bastantes temas y mensajes que me hacen dar bastante verguenza :rolleyes: yo a este foro, y lo admito, llegué como un completo lammer y sin saber ni p##a idea de qué iba un foro.

A este tipo de foros se suele llegar sin saber mucho o sabiendo nada, y solo el tiempo otorga la experiencia, durante ese tiempo lo más seguro es que la inexperiencia haga publicar chorradas tremendas ...preguntas de novato;
cuando ya se ha adquirido cierto nivel de experiencia en eso que preguntaste hace unos años es cuando se siente verguenza de que ese post siga visible para cualquiera, por que quizás quien vea eso pensará que eres un noob/lammer, y quizás ahora ya no lo seas, pero el caso es que lo fuiste cuando escribiste esa chorrada, forma parte de ti cómo de cualquiera de nosotros, no hay por que avergonzarse y de hecho hay que saber aceptarlo para NO VENIRSE ARRIBA, no creerse superior, por que todos hemos sido noobs/lammers en algún momento de nuestras vidas, y que los posts sigan ahí es algo positivo por que siempre viene bien recordar que la experiencia se ha ganado a base de cometer errores.

No solo me estoy poniendo en la piel del otro, yo hablo por propia experiencia, que en el foro hay infinidad de posts de mi antiguo usuario donde muestro completa ignorancia sobre bastantes temas informáticos y lo que más verguenza me causa es que yo parecía (bueno, era) un paleto haciendo preguntas sobre programación en Batch (el lenguaje más simple del mundo), cosas cómo esa y otras cosas que ahora controlo de sobra.

Saludos!
5510  Programación / .NET (C#, VB.NET, ASP) / Re: Evitar datos duplicados en listview en: 10 Mayo 2015, 10:53 am
No estás haciendo nada mal, simplemente la llave no se encuentra por que las minúsculas/mayúsculas no coinciden, o el texto que estás buscando no existe cómo llave.

Para condicionar el resultado, asigna la llave de los items en minúscula:
Código
  1. Dim articulo As String = "Clavos"
  2. Dim cantidad As Integer = 40
  3.  
  4. Dim lvItem As New ListViewDataItem(text:="", values:={articulo, cantidad.ToString("00")}) With
  5.    { .Key = articulo.Trim.ToLower }
  6.  
  7. Me.RadListView1.Items.Add(lvItem)

Y entonces busca en minúscula:
Código
  1. Dim articulo As String = txtArticulosPedidos.Text.Trim
  2. Dim cantidad As String = Convert.ToInt32(rseCantidadPedido.Text).ToString("00")
  3.  
  4. If Me.lvListaPedidos.FindItemByKey(key:=articulo.ToLower, searchVisibleItems:=True) IsNot Nothing Then
  5.    RadMessageBox.Show("El articulo ya existe en la lista.", "", MessageBoxButtons.OK, RadMessageIcon.Error)
  6. Else
  7.    Dim lvItem As New ListViewDataItem(text:="", values:={articulo, cantidad} with
  8.        { .Key = articulo.ToLower }
  9.    Me.lvListaPedidos.Items.Add(lvItem)
  10. End If

Saludos
Páginas: 1 ... 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 [551] 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 ... 1253
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines