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

#7331
¿Que es la programación orientada a objetos?: Las respuesta rápida y sencilla (eliminando todos los tecnicismos que habrás leido por ahi) sería: Un estilo de programación (un paradigma de programación), ni más, ni menos, donde, obviamente, se maneja la implementación del concepto 'objetos'.

¿Y que es un objeto?: Pues prácticamente es un término/concepto (esto es algo que está muy bien explicado por la Wikipedia), un objeto es un espacio en la memoria (Si, la memoria RAM del PC, para no dejar dudas) al que se le asigna un valor respectívamente de un identificador. Dicho espacio puede contener una variable o una función entera. Y en la programación orientada a objetos, el término objeto se usa para referirse a aquellos 'objetos' instanciados por una Class, en fin, variables que instancian una Class que se usará en tiempo de ejecución.

Básicamente la programación orientada a objetos te permite infinidad de mejoras/optimizaciones en tiempo de ejecución, aparte de los ya conocidos objetos, por ejemplo, el uso de enlaces dinámicos: http://es.wikipedia.org/wiki/Enlace_din%C3%A1mico_%28programaci%C3%B3n_orientada_a_objetos%29
Y en fin ...todo lo demás que puedes ver en un lenguaje orientado a objetos.

Te muestro un ejemplo del uso de un objeto, en VB.NET:

Código (vbnet) [Seleccionar]
Public Class Form1

   ' Declaro una variable (un objeto) donde hay instanciado un Form (Es una Class)
   ' Fíjate en el operador 'New', esto llama al método "New" (El constructor) dentro de la Class, para instanciarla.
   Dim MiObjeto As Form = New Form

   Private Shadows Sub Load() Handles MyBase.Load

       ' Establezco algunas propiedades del objeto (es decir, del Form).
       With MiObjeto
           .Text = "Form2" ' El título del Form.
           .WindowState = FormWindowState.Maximized ' El estado de la ventana (Maximizada).
           .ShowDialog() ' Y por último, llamo al método 'ShowDialog' para mostrar el Form instanciado.
       End With

       Application.Exit()

   End Sub

End Class


Cita de: Linton en  4 Febrero 2014, 08:25 AMno consigo ver cuáles son las ventajas, ya que no sé cómo se programaba antes  :huh:

Pues no tienes que irte muy lejos ni retroceder muchos años atrás!!!, basta con que hallas usado uno de los lenguajes nativos en Windows o Linux ...Batch o Bash, entonces te puedes hacer una inmensa idea sobre la cantidad de diferencias que tienen estos lenguajes de programación, en especial la morralla de Batch en comparación con cualquier otro lenguaje, Batch es un tipo de programación, si es que se le puede llamar así al 'procesamiento por lotes'.

Otros estilos de programación (paradigmas de programación) que están por debajo de la escala evolutiva de la programación orientada a objetos (seguro que por este comentario vendrá el típico listo a decir que si X lenguaje de programación es peor que otro y blablabla... que cada uno se lo tome como quiera) serían la programación estructurada ('structured programming paradigm') o 'procedural programming' o 'imperative programming', como por ejemplo C y C++ (no C#) (Aunque por otro lado C++ soporta el estilo de programación orientada a objetos pero básicamente se basa en C, así que se queda como procedural), Pascal, Basic y otros derivados de Basic como QBasic PureBasic o VisualBasic (VB6, no VB.NET), Perl, etc...

Y también el estilo de programación 'expression oriented language', donde como su nombre indica tódas las órdenes o la mayoría de ellas (excepto las declaraciones) son expresiones y se tratan como tal por el compilador (me imagino), un ejemplo de este paradigma de programación sería el lenguaje 'LISP' de los años 50 (me he tenido que informar sobre esto en la wikipedia, no me tomes por un erudito que lo sabe todo).



Y bueno, después de toda esta parrafada, solo te puedo dar una mi más sincera opinión:

No importa que ahora mismo no seas capaz de darte cuenta de las diferencias de programación o de las ventajas de los objetos, y que segúramente oigas comentar a la gente que C++ es el mejor lenguaje ...pero lo será para ellos, la verdad es que no es un lenguaje orientado a objetos (de forma completa) y bueno, solo lo comento porque me ciño a tu duda, no odio a C++, lo respeto como el gran lenguaje que es, pero la elección debe ser tuya y no de los que desde los años 80 no saben ver más hallá de C/C++, en fín yo te aseguro que una vez que hayas usado un lenguaje complétamente orientado a objetos (VB.NET, C#, Java, etc...)... no querrás probar otra cosa y verás lo ridículamente inferiores que son todos los demás lenguajes que llegues a probar o que ya hayas probado ;).

Saludos!
#7332
Windows / Re: abrir fmc con 5 veces mayus
3 Febrero 2014, 20:38 PM
Aún no me imagino que tipo de confusión te ha podido llevar a escribir 'fmc' en lugar de CMD, pero porfavor, corrige el título de tu post y usa el botón modificar en tu primer comentario para corregirlo también, respeta las normas del foro, no hagas doble post.

Saludos!
#7333
Windows / Re: Auditar fecha creación archivos
3 Febrero 2014, 20:34 PM
Depende, si quieres una GUI, quédate con el programa que te recomendó el compañero 0xefro, pero si por otro lado quieres automatizar la tarea por consola con un programa CLI entonces te recomiendo el software que hice yo (el cual supera con creces a otros programas similares con interface commandline como por ejemplo FileTouch):



~> FileDate | Autor: EleKtro

Un ejemplo, para obtener todas las fechas de todos los archivos de todos los subdirectorios del directorio actual puedes usar este comando:
FileDate.exe -Get /R /V /C /M /A "%CD%"

Otro ejemplo, para cambiar todas las fechas a todos los archivos de todos los subdirectorios del directorio actual puedes usar este comando:
FileDate.exe -Set /R /V /C /M /A "01/01/2013" "%CD%"

PD: Para archivos individuales puedes usar un For, y para modificar fechas de forma individual puedes leerte la ayuda del comando, en la página que comenté arriba o desde el propio programa.

Saludos!
#7334
Al final, como dije, añadí estas opciones al menú contextual (para archivos executables sólamente)



También hice un instalador, si alguien lo quiere... ~> http://www.mediafire.com/download/e8chmiqq6behvmc/Firewall.exe

Un saludo!
#7335
Cita de: luis456 en  3 Febrero 2014, 13:15 PM12 13 55 <--asi es que me hacen falta

¿Y esta linea no te dice nada?:

Código (vbnet) [Seleccionar]
TextBox2.Text = String.Join("; ", RandomizeArray(IntArray))

...Es que vamos!!!, Luis, joer... esta claro q no hay manera...

Para separar los números por un espacio, pues, muy óbviamente, debes modificar el string que usas como separador:

String.Join(Separador, Colección)

Ejemplo:
Código (vbnet) [Seleccionar]
MsgBox(String.Join(Convert.ToChar(Keys.Space), {1I, 2I, 3I, 4I, 5I}.ToArray))


Y para lo de seleccionar "pares" de elementos no te aconsejo hacelro desde la función, haz las cosas de forma ordenada,
primero desordenas todos los elementos del array, y luego ese array desordenado (que contiene todos los números) lo usas para ir sacando los que quieras ...esto lo puedes automatizar con un For o usando Linq:

Código (vbnet) [Seleccionar]
Public Class Form1

   Private Shadows Sub Shown() Handles MyBase.Shown

       Dim Elementos As Integer() =
       {
         1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
         11, 12, 13, 14, 15, 16, 17, 18
       }

       For X As Integer = 0 To Elementos.Count - 1 Step 4

           MessageBox.Show(
               String.Format("{0} {1} {2} {3}",
                   Elementos(X),
                   If(Not (X + 1) >= Elementos.Count, Elementos(X + 1), String.Empty),
                   If(Not (X + 2) >= Elementos.Count, Elementos(X + 2), String.Empty),
                   If(Not (X + 3) >= Elementos.Count, Elementos(X + 3), String.Empty),
                   "Cuatro Elementos"
               )
           )

       Next X

       Application.Exit()

   End Sub

End Class



O puedes hacerlo de forma mas manual:
Código (vbnet) [Seleccionar]
    Public Class Form1

    Private Sub Form1_Load() Handles MyBase.Load

        Dim Elementos As Integer() =
        {
          1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
          11, 12, 13, 14, 15, 16, 17, 18
        }

        Dim Cantidad As Integer = 4

        Dim Primeros_Cuatro_Elementos As Integer() =
            (From Elemento As Integer In Elementos
             Take Cantidad).ToArray

        Dim Siguientes_Cuatro_Elementos As Integer() =
            (From Elemento As Integer In Elementos
             Skip Primeros_Cuatro_Elementos.Count
             Take Cantidad).ToArray

        Dim Todo_El_Resto_De_Elementos As Integer() =
            (From Elemento As Integer In Elementos
             Skip Primeros_Cuatro_Elementos.Count _
             +
             Siguientes_Cuatro_Elementos.Count).ToArray

        MessageBox.Show(String.Join(Convert.ToChar(Keys.Space), Primeros_Cuatro_Elementos), "Primeros_Cuatro_Elementos")
        MessageBox.Show(String.Join(Convert.ToChar(Keys.Space), Siguientes_Cuatro_Elementos), "Siguientes_Cuatro_Elementos")
        MessageBox.Show(String.Join(Convert.ToChar(Keys.Space), Todo_El_Resto_De_Elementos), "Todo_El_Resto_De_Elementos")

        Application.Exit()

    End Sub

End Class


Saludos.
#7336
Bueno, he codeado este mini Script para determinar si un proceso (existente) tiene las conexiones entrantes o salientes bloqueadas por el firewall de Windows.

Mi intención es usar este script desde unas opciones que crearé en el menú contextual de Windows para bloquear conexiones, desbloquear, y comprobar si un proceso ya está bloqueado.

EDITO: Mejorado.
Código (vb) [Seleccionar]
' *********************
' FirewallRuleCheck.vbs
' *********************
' By Elektro


' ------------
' Description:
' ------------
'
' This script determines whether a program has the Inbound or Outbound connections blocked by the Windows Firewall rules.
'
' NOTE: Possibly this script will not work under Windows XP where;
'       the Netsh syntax is different and maybe the Firewall registry values could be diferent too, I've don't tested it.
'       Tested on Windows 8.


' -------
' Syntax:
' -------
'
' FirewallRuleCheck.vbs "[File]" "[ConnectionType]" "[ReturnResult]"


' -----------
' Parameters:
' -----------
'
' [File]
' This parameter indicates the file to check their connection status.
' The value should be the relative or absolute filepath of an existing file.
'
' [ConnectionType]
' This parameter indicates whether to check inbound or outbound connection status.
' The value should be "In" or "Out".
'
' [ReturnResult]
' This parameter indicates whether the result should be returned without displaying any info;
' for example, when calling this script from other script to expect a Boolean result.
' The value is Optional, and should be "True" or "False". Default value is "False".


' ---------------
' Usage examples:
' ---------------
'
' FirewallRuleCheck.vbs "C:\Program.exe"  IN
' FirewallRuleCheck.vbs "C:\Program.exe" OUT
' BooleanExitCode = FirewallRuleCheck.vbs "C:\Program.exe"  IN True
' BooleanExitCode = FirewallRuleCheck.vbs "C:\Program.exe" OUT True


' -----------
' Exit codes:
' -----------
'
' When 'ReturnResult' parameter is set to 'False':
'      0: Successful exit.
'      1: Missing arguments or too many arguments.
'      2: File not found.
'      3: Wrong value specified for parameter '[ConnectionType]'
'      4: Wrong value specified for parameter '[ReturnResult]'
'      5: Specific Error.
'
' When 'ReturnResult' parameter is set to 'True':
'     -1: 'True'  (Rule is not added).
'      0: 'False' (Rule is already added).
'      (All the other ExitCodes: '1', '2', '3', '4' and '5' can happen in this mode, except '0')


' *************
Option Explicit

Const MsgBoxSyntax   = "FirewallRuleCheck.vbs ""[File]"" ""[ConnectionType]"" ""[ReturnResult]"""
Const MsgBoxCaption  = "Firewall Rule Check"
Const MsgBoxErrorIco = 16
Const MsgBoxInfoIco  = 64
Const MsgBoxDebugIco = 48

Dim objFile        ' Indicates the file object.
Dim objReg         ' Indicates the registry object.
Dim Root           ' Indicates the root registry key.
Dim Key            ' Indicates the registry key.
Dim MatchData      ' Indicates the data to match.
Dim Values         ' Indicates the registry value collection.
Dim Value          ' Indicates the registry value.
Dim Data           ' Indicates the registry data.
Dim DataIsMatched  ' Indicates whether the data is matched.
Dim ConnectionType ' Indicates whether to check inbound or outbound connection status.
Dim ReturnResult   ' Indicates whether the result should be returned without displaying any info;
                  ' for example, when calling this script from other script to expect a Boolean result.
Dim DebugMode      ' Indicates whether the debug mode is activated.


' Set the debug mode to 'True' if need to test the values.
DebugMode = False

' Set the 'HKEY_LOCAL_MACHINE' as Root registry key.
Root = &H80000002

' Set the Firewall rules registry location as key.
Key = "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\FirewallRules"

' Sets the Registry object.
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

' Argument error handling.
If Wscript.Arguments.Count = 0 Then

' Notify the error to the user.
MsgBox "Syntax:" & VBNewLine & _
      MsgBoxSyntax          , _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Missing arguments'.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count < 2 Then

' Notify the error to the user.
MsgBox "Missing arguments."  & _
      VBNewLine & VBNewLine & _
      "Syntax:" & VBNewLine & _
      MsgBoxSyntax          , _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Missing arguments'.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count = 3 Then

If LCase(Wscript.Arguments(2)) = LCase("True") Then
ReturnResult = True

Elseif LCase(Wscript.Arguments(2)) = LCase("False") Then
ReturnResult = False

Else

' Notify the error to the user.
MsgBox "Wrong value specified for parameter 'Return Result'", _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Wrong value specified for parameter '[Return Result]''.
Wscript.Quit(4)

End If

ElseIf Wscript.Arguments.Count > 3 Then

' Notify the error to the user.
MsgBox "Too many arguments." & _
      VBNewLine & VBNewLine & _
      "Syntax:" & VBNewLine & _
      MsgBoxSyntax          , _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Too many arguments'.
Wscript.Quit(1)

End If

On Error Resume Next

' Set the FileObject with the file passed through the first argument.
Set objFile = Createobject("Scripting.FileSystemObject"). _
             GetFile(Wscript.Arguments(0))

' File-Error handling.
If Err.Number = 53 Then

' Notify the error to the user.
MsgBox "File not found:"   & _
      vbnewline           & _
      Wscript.Arguments(0), _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'File not found'.
Wscript.Quit(2)

End If

' Set the partial data to match on each value-data.
If LCase(Wscript.Arguments(1)) = LCase("IN") Then

' Set the ConnectionType to 'Inbound'
ConnectionType = "Inbound"

Elseif LCase(Wscript.Arguments(1)) = LCase("OUT") Then

' Set the ConnectionType to 'Outbound'
ConnectionType = "Outbound"

Else ' Wrong argument.

' Notify the error to the user.
MsgBox "Wrong value specified for parameter '[ConnectionType]'", _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Wrong value specified for parameter '[ConnectionType]''.
Wscript.Quit(3)

End If

' Set the data to match (It's a portion of the firewall rule).
MatchData = "Action=Block|Active=TRUE|Dir=" & Wscript.Arguments(1) & "|App=" & objFile.Path

' Enumerate the registry values.
objReg.EnumValues Root, Key, Values

If DebugMode Then

' Notify the debug information.
MsgBox "File: "            & objFile.Path   & vbnewline & vbnewline & _
      "ConnectionType: "  & ConnectionType & vbnewline & vbnewline & _
      "Key: "             & Key            & vbnewline & vbnewline & _
      "Value count: "     & UBound(Values) & vbnewline & vbnewline & _
      "MatchData: "       & MatchData      & vbnewline             , _
      MsgBoxDebugIco,     "Debug Info | "  & MsgBoxCaption

End If

' Loop through the enumerated registry values.
For Each Value In Values

' Get the registry data.
objReg.GetStringValue Root, Key, Value, Data

' If registry data is not empty then...
If Not IsNull(Data) Then
' Match the partial data onto the registry data.

' If partial data matched in into the data then...
If InStr(1, Data, MatchData, 1) Then

' Set the DataIsMatched flag to 'True'.
DataIsMatched = True

' ...and stop the iteration.
Exit For

End If ' // InStr()

End If ' // IsNull()

Next ' // Value

' Error handling.
If Err.Number <> 0 Then

' Notify the error to the user.
MsgBox "Error Code: "   & Err.Number & vbnewline & _
      "Error Source: " & Err.Source & vbnewline & _
      "Description: "  & Err.Description        , _
      MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Specific error'.
Wscript.Quit(5)

End If

If ReturnResult Then

If DataIsMatched = True Then
' Exit with boolean result 'True' (Rule already exist).
Wscript.Quit(-1)
Else
' Exit with boolean result 'False' (Rule doesn't exist).
Wscript.Quit(0)
End If

End If

' This (ridiculous) conversion is needed;
' because the VBS engine prints the boolean value into a MsgBox;
' according to the OS language ( Spanish: Verdadero|Falso )
If DataIsMatched = True Then
DataIsMatched = "True"
Else
DataIsMatched = "False"
End If

' Notify the information to the user.
MsgBox "File: "       & objFile.Name    & vbnewline & _
      "Connection: " & ConnectionType  & vbnewline & _
      "Blocked?: "   & DataIsMatched               , _
      MsgBoxInfoIco, MsgBoxCaption

' Exit successfully.
Wscript.Quit(0)


Ejemplos de uso:

Wscript.exe ThisScript.vbs "C:\Program.exe" IN

Wscript.exe ThisScript.vbs "C:\Program.exe" OUT

PD: No sé si funcionará en WindowsXP, por que Netsh usa una sintaxis distinta a las versiones posteriores de Windows y supongo que en los valores de las claves de las reglas del Firewall también se verán reflejados estos cambios de sintaxis, no lo sé, no lo he comprobado.

Saludos!






Otro script, para añadir reglas de bloqueo de conexiones entrantes o salientes del firewall de Windows:

( Estos scripts dependen del primer script, 'FirewallRuleCheck.vbs', puesto que llaman a dicho script para verificar si una regla existe o si no existe )

EDITO: Mejorado
Código (vb) [Seleccionar]
' *******************
' FirewallRuleAdd.vbs
' *******************
' By Elektro


' ------------
' Description:
' ------------
'
' This Script adds a Firewall rule to block the Inbound or Outbound connections of a file.
'
' NOTE: Possibly this script will not work under Windows XP where;
'       the Netsh syntax is different and maybe the Firewall registry values could be diferent too, I've don't tested it.
'       Tested on Windows 8.


' -------
' Syntax:
' -------
'
' FirewallRuleAdd.vbs "[File]" "[ConnectionType]"


' -----------
' Parameters:
' -----------
'
' [File]
' This parameter indicates the file to block.
' The value should be the relative or absolute filepath of an existing file.
'
' [ConnectionType]
' This parameter indicates whether to add a rule to block inbound or outbound connections.
' The value should be "In" or "Out".


' ---------------
' Usage examples:
' ---------------
'
' FirewallRuleAdd.vbs "C:\Program.exe" IN
' FirewallRuleAdd.vbs "C:\Program.exe" OUT


' -----------
' Exit codes:
' -----------
'
' -1: Rule already exist.
'  0: Successful exit.
'  1: Missing arguments or too many arguments.
'  2: File not found.
'  3: Wrong value specified for parameter '[ConnectionType]'
'  4: Specific Error.


' *************
Option Explicit

Const MsgBoxSyntax   = "FirewallRuleAdd.vbs ""[File]"" ""[ConnectionType]"""
Const MsgBoxCaption  = "Firewall Rule Add"
Const MsgBoxErrorIco = 16
Const MsgBoxInfoIco  = 64
Const MsgBoxDebugIco = 48

Dim objFile        ' Indicates the File Object.
Dim Process        ' Indicates the process to run.
Dim Arguments      ' Indicates the process arguments.
Dim Result         ' Indicates the result (Exit Code) of the process.
Dim ConnectionType ' Indicates whether to block inbound or outbound connections.
Dim DebugMode      ' Indicates whether the debug mode is activated.


' Set the debug mode to 'True' if need to test the values.
DebugMode = False

' Argument error handling.
If Wscript.Arguments.Count = 0 Then

' Notify the error to the user.
MsgBox "Syntax:" & VBNewLine & _
       MsgBoxSyntax          , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Missing arguments' error-code.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count < 2 Then

' Notify the error to the user.
MsgBox "Missing arguments."  & _
       VBNewLine & VBNewLine & _
       "Syntax:" & VBNewLine & _
       MsgBoxSyntax          , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Missing arguments'.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count > 2 Then

' Notify the error to the user.
MsgBox "Too many arguments." & _
       VBNewLine & VBNewLine & _
       "Syntax:" & VBNewLine & _
       MsgBoxSyntax          , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Too many arguments'.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count = 2 Then

If LCase(Wscript.Arguments(1)) = LCase("IN") Then

' Set the ConnectionType to 'Inbound'
ConnectionType = "Inbound"

Elseif LCase(Wscript.Arguments(1)) = LCase("OUT") Then

' Set the ConnectionType to 'Outbound'
ConnectionType = "Outbound"

Else ' Wrong argument.

' Notify the error to the user.
MsgBox "Wrong value specified for parameter '[ConnectionType]'", _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Wrong value specified for parameter '[ConnectionType]''.
Wscript.Quit(3)

End If

End If

On Error Resume Next

' Set the FileObject with the file passed through the first argument.
Set objFile = Createobject("Scripting.FileSystemObject"). _
              GetFile(Wscript.Arguments(0))

' File-Error handling.
If Err.Number = 53 Then

' Notify the error to the user.
MsgBox "File not found:"   & _
       vbnewline           & _
       Wscript.Arguments(0), _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'File not found'.
Wscript.Quit(2)

End If

' Set the firewall process.
Process   = "netsh.exe"

' Set the firewall rule parameters to add Inbound or Outbound blocking rule.
Arguments = "AdvFirewall Firewall Add Rule"       & _
            " Name=" & """" & objFile.Name & """" & _
            " Dir="  & Wscript.Arguments(1)       & _
            " Action=Block"                       & _
            " Program=" & """" & objFile.Path & """"

' Call the 'FirewallRuleCheck' script to retrieve their exit code;
' This way I determine whether the bloking rule already exist or not.
Result = WScript.CreateObject("WScript.Shell"). _
         Run("FirewallRuleCheck.vbs"    & " " & _
             """" & objFile.Path & """" & " " & _
             Wscript.Arguments(1)       & " " & _
             "True", 0, True)

If DebugMode Then

' Notify the debug information.
MsgBox "File: "            & objFile.Path   & vbnewline & vbnewline & _
       "ConnectionType: "  & ConnectionType & vbnewline & vbnewline & _
       "Process: "         & Process        & vbnewline & vbnewline & _
       "Arguments: "       & Arguments      & vbnewline & vbnewline & _
       "Reult: "           & Result         & vbnewline             , _
       MsgBoxDebugIco,     "Debug Info | "  & MsgBoxCaption

End If

' Error handling.
If Err.Number <> 0 Then

' Notify the error to the user.
MsgBox "Error Code: "   & Err.Number & vbnewline & _
       "Error Source: " & Err.Source & vbnewline & _
       "Description: "  & Err.Description        , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Specific error'.
Wscript.Quit(5)

End If

If Result = -1 Then ' Rule already exist.

' Notify the error to the user.
MsgBox ConnectionType & " connection blocking rule already exist for file:" & _
       vbnewline                                                            & _
       objFile.Name                                                         , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Rule already exist'.
Wscript.Quit(-1)

Else ' Rule added successfully.

WScript.CreateObject("WScript.Shell").Run Process & " " & Arguments, 0, True

' Notify the information to the user.
MsgBox ConnectionType & " connection blocking rule successfully added for file:" & _
       vbnewline                                                                 & _
       objFile.Name                                                              , _
       MsgBoxInfoIco, MsgBoxCaption

End If

' Exit successfully.
Wscript.Quit(0)







Y otro para eliminar reglas:

EDITO: Mejorado
Código (vb) [Seleccionar]
' *******************
' FirewallRuleDel.vbs
' *******************
' By Elektro


' ------------
' Description:
' ------------
'
' This Script deletes an existing firewall rule that is blocking the Inbound or Outbound connections of a file.
'
' NOTE: Possibly this script will not work under Windows XP where;
'       the Netsh syntax is different and maybe the Firewall registry values could be diferent too, I've doesn't tested it.
'       Tested on Windows 8.


' -------
' Syntax:
' -------
'
' FirewallRuleDel.vbs "[File]" "[ConnectionType]"


' -----------
' Parameters:
' -----------
'
' [File]
' This parameter indicates the file to block.
' The value should be the relative or absolute filepath of an existing file.
'
' [ConnectionType]
' This parameter indicates whether to delete the rule that is blocking inbound or outbound connections.
' The value should be "In" or "Out".


' ---------------
' Usage examples:
' ---------------
'
' FirewallRuleDel.vbs "C:\Program.exe" IN
' FirewallRuleDel.vbs "C:\Program.exe" OUT


' -----------
' Exit codes:
' -----------
'
' -1: Rule doesn't exist.
'  0: Successful exit.
'  1: Missing arguments or too many arguments.
'  2: File not found.
'  3: Wrong value specified for parameter '[ConnectionType]'
'  4: Specific Error.


' *************
Option Explicit

Const MsgBoxSyntax   = "FirewallRuleDel.vbs ""[File]"" ""[ConnectionType]"""
Const MsgBoxCaption  = "Firewall Rule Del"
Const MsgBoxErrorIco = 16
Const MsgBoxInfoIco  = 64
Const MsgBoxDebugIco = 48

Dim objFile        ' Indicates the File Object.
Dim Process        ' Indicates the process to run.
Dim Arguments      ' Indicates the process arguments.
Dim Result         ' Indicates the result (Exit Code) of the process.
Dim ConnectionType ' Indicates whether to unblock inbound or outbound connections.
Dim DebugMode      ' Indicates whether the debug mode is activated.


' Set the debug mode to 'True' if need to test the values.
DebugMode = False

' Argument error handling.
If Wscript.Arguments.Count = 0 Then

' Notify the error to the user.
MsgBox "Syntax:" & VBNewLine & _
       MsgBoxSyntax          , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Missing arguments' error-code.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count < 2 Then

' Notify the error to the user.
MsgBox "Missing arguments."  & _
       VBNewLine & VBNewLine & _
       "Syntax:" & VBNewLine & _
       MsgBoxSyntax          , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Missing arguments'.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count > 2 Then

' Notify the error to the user.
MsgBox "Too many arguments." & _
       VBNewLine & VBNewLine & _
       "Syntax:" & VBNewLine & _
       MsgBoxSyntax          , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Too many arguments'.
Wscript.Quit(1)

ElseIf Wscript.Arguments.Count = 2 Then

If LCase(Wscript.Arguments(1)) = LCase("IN") Then

' Set the ConnectionType to 'Inbound'
ConnectionType = "Inbound"

Elseif LCase(Wscript.Arguments(1)) = LCase("OUT") Then

' Set the ConnectionType to 'Outbound'
ConnectionType = "Outbound"

Else ' Wrong argument.

' Notify the error to the user.
MsgBox "Wrong value specified for parameter '[ConnectionType]'", _
   MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Wrong value specified for parameter '[ConnectionType]''.
Wscript.Quit(3)

End If

End If

On Error Resume Next

' Set the FileObject with the file passed through the first argument.
Set objFile = Createobject("Scripting.FileSystemObject"). _
              GetFile(Wscript.Arguments(0))

' File-Error handling.
If Err.Number = 53 Then

' Notify the error to the user.
MsgBox "File not found:"   & _
       vbnewline           & _
       Wscript.Arguments(0), _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'File not found'.
Wscript.Quit(2)

End If

' Set the firewall process.
Process   = "netsh.exe"

' Set the firewall rule parameters to delete Inbound or Outbound blocking rule.
Arguments = "AdvFirewall Firewall Delete Rule"    & _
            " Name=" & """" & objFile.Name & """" & _
            " Dir="  & Wscript.Arguments(1)

' Call the 'FirewallRuleCheck' script to retrieve their exit code;
' This way I determine whether the bloking rule is exist or not.
Result = WScript.CreateObject("WScript.Shell"). _
         Run("FirewallRuleCheck.vbs"    & " " & _
             """" & objFile.Path & """" & " " & _
             Wscript.Arguments(1)       & " " & _
             "True", 0, True)

If DebugMode Then

' Notify the debug information.
MsgBox "File: "            & objFile.Path   & vbnewline & vbnewline & _
       "ConnectionType: "  & ConnectionType & vbnewline & vbnewline & _
       "Process: "         & Process        & vbnewline & vbnewline & _
       "Arguments: "       & Arguments      & vbnewline & vbnewline & _
       "Reult: "           & Result         & vbnewline             , _
       MsgBoxDebugIco,     "Debug Info | "  & MsgBoxCaption

End If

' Error handling.
If Err.Number <> 0 Then

' Notify the error to the user.
MsgBox "Error Code: "   & Err.Number & vbnewline & _
       "Error Source: " & Err.Source & vbnewline & _
       "Description: "  & Err.Description        , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Specific error'.
Wscript.Quit(5)

End If

If Result = 0 Then ' Rule doesn't exist.

' Notify the error to the user.
MsgBox ConnectionType & " connection blocking rule doesn't exist for file:" & _
       vbnewline                                                            & _
       objFile.Name                                                         , _
       MsgBoxErrorIco, MsgBoxCaption

' Exit with reason: 'Rule doesn't exist'.
Wscript.Quit(-1)

Else ' Rule deleted successfully.

WScript.CreateObject("WScript.Shell").Run Process & " " & Arguments, 0, True

' Notify the information to the user.
MsgBox ConnectionType & " connection block rule successfully deleted for file:" & _
       vbnewline                                                                & _
       objFile.Name                                                             , _
       MsgBoxInfoIco, MsgBoxCaption

End If

' Exit successfully.
Wscript.Quit(0)
#7337
@Kurono90

Perdona por tardar en contestar.

Muchas gracias por la ayuda y el detalle que te has tomado de extender las explicaciones, sin duda es genial.

Lo de la unión de los archivos MP3 era cosa facil para mi, no pedí ayuda para eso, me sabe mal que te hayas molestado tanto en explicarme eso, no era necesario la verdad :P

La idea de tener que usar el avisynth para la tarea junto a un conversor de video te lo agradezco pero no me agrada mucho la idea porque yo lo que reálmente quería evitar era tener que especificar la cantidad de loops (como muestras en el script de AviSynth) porque voy a usar Audios de duración indeterminda y también Videos de duración indeterminada;

así que me puse a indagar una solución alternativa y descubrí que en el AfterEffects, existe una opción para hacer un Loop infinito de la pista de video hasta la duración total de la pista de audio, sin necesidad de especificar la cantidad de veces que el video tiene que repetirse, el problema es que no hay manera de automatizar el aplicado de efectos en el AfterEffects (al menos, que yo sepa) y además es necesario la recompresión del video (o al menos, eso creo);

y al final decidí usar el VirtualDubMod y copiar la pista de video (CTRL+C, CTRL+V, más sencillo imposible) hasta que dure lo mismo que la pista de audio, y al menos, esto no requiere recompresión y es un programa que consume escasos recursos, pero tengo el mismo problema... no veo modo de automatizar esta tarea con el VDubMod, así que estoy igual que como empecé.

¿No sabrás si el FFMPEG soporta la inserción de un script AviSynth? (en la documentación oficial no veo parámetros para esto, pero son infinitos y quizás se me ha pasado),
porque se me acaba de ocurrir que sería un procedimiento muy facil de automatizar desde la consola:

1. Desarrollar una mini-aplicación para medir la duración de la pista de Video y la de audio (o en su defecto usar MediaInfo CLI para obtener la duración) y hacer los cálculos necesarios.
2. Escribir de forma automática el script de AviSyth usando el valor adecuado en el parámetro "Loop()" (según los cálculos obtenidos en el primer paso).
3. Muxear las pistas usando FFMPEG, usando el script de avisynth para repetir el bucle del video (si es necesario la recompresión para hacer el loop pues bueno, no me importaría de esta manera).

PD: Solo necesitaría ayuda para saber como es la sintaxis adecuada para usar AviSynth en FFMPEG (si fuese posible usarlo)


Un saludo!
#7338
Multimedia / Re: Alternativa a DVDFab
3 Febrero 2014, 09:28 AM
No, al hacer un copy de un DVD entra en juego el Muxeado el Copiado y el Ripeo, porque:

1. Eliminas pistas
2. Comprimes las pistas
3. Copias las pistas

Por esa razón, se denomina 'Rip' en toda regla, la re-codificación es simplemente eso ...codificación, no quieras hacer de la codificación el conjunto total del Ripping ...porque no lo es, los programas 'Rippers', además de recodificar el video, también lo remuxean, así que si no quieres reconocerlo a pesar de mis explicaciones y las de Wikipedia ...pues bueno, no es mi problema, pero creo que ha quedado bastante claro, y yo voy a dejar de discutir este tema porque no tengo que dar explicaciones porque venga un chaval a querer intentar ilustrar dandome lecciones a mi y a los demás sobre las diferencias (erroneas) entre A y B, diferencias que ya conozco de sobra puesto que llevo en este mundillo desde antes de que nacieras, y para colmo decirme que si no encuentro software es porque lo busco las cosas mal ...en fín.

PD: Porfavor, si algún mod lee esto, cierren el tema ya...

Saludos!
#7339
Multimedia / Re: Alternativa a DVDFab
3 Febrero 2014, 08:26 AM
Siento decirlo, pero, como otro dato cultural, te equivocas, el término correcto es ripear (Ripping):
Cita de: WikipediaRipping is the process of copying audio or video content to a hard disk, typically from removable media such as compact disc (CD) or DVD
Ripping is often used to shift formats, and to edit, duplicate or back up media content.

¿Nunca has escuchado la expresión "Ripear un juego"?, pues al ripear un DVD de video no creo que se muxeen las pistas, en todo caso se demuxea (si eliminas alguna pista/subtiulo) pero sin volver a unir las demás, y también se puede comprimir (de un DVD9 a DVD5) desde estos programas, lo que envuelve aún más el termino ripear y/o codificar.

Óbviamente encontrarás productos que se denominen "DVD Ripper" (EJ: StaxRip) que cumplan funciones de conversión (codificación) de video, porque también es el término correcto en este contexto.

Respecto al otro comentario (dejando claro con esto que óbviamente he buscado por Rip, ya que es el término correcto), simplemente hay demasiada basura en el software que se puede encontrar hoy en dia por internet, no ha sido nada facil encontrar un software que tenga las mismas características que DVDFab, no vas a encontrar un producto que se llame "DVD Muxer" y esperar que hagan rips.

Un saludo!
#7340
Windows / Re: Registro Bloqueado windows 7
3 Febrero 2014, 07:56 AM
hola, te aclaro tus dudas:

1. Puedes usar RegAlyzer y programas parecidos para mirar y/o modificar cualquier clave de registro incluso aunque tengas la restricción del Regedit activado en las políticas de usuario o aunque intentes modificar una clave en la que no tengas permisos suficientes de usuario.

2. Los cambios en las políticas de usuario (como el script que has mostrado del registro) si que funcionan, pero muchos cambios en el sistema requieren cerrar sesión/reiniciar el PC para que los cambios surgan efecto, y modificar las políticas de usuario es uno de esos casos que lo requieren.

3. Con el script de tu ejemplo no se consigue modificar el valor, la sintaxis de un script de Regedit es muy estricta, y debe quedar así:

Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\system]
"DisableRegistryTools"=dword:00000000


Si pones el valor y los datos a la derecha de la clave como en tu ejemplo, no da error, pero automáticamente se omite.

Saludos