|
7472
|
Programación / .NET (C#, VB.NET, ASP) / Re: Combinaciones letras o numeros
|
en: 3 Febrero 2014, 19:01 pm
|
12 13 55 <--asi es que me hacen falta ¿Y esta linea no te dice nada?: 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: 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: 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: 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.
|
|
|
7473
|
Programación / Scripting / [APORTE] [VBS] Snippets para manipular reglas de bloqueo del firewall de Windows
|
en: 3 Febrero 2014, 11:56 am
|
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. ' ********************* ' 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 ' ******************* ' 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 ' ******************* ' 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)
|
|
|
7474
|
Media / Multimedia / Re: ¿Cual seria la mejor forma de automatizar esta tarea para crea video musical?...
|
en: 3 Febrero 2014, 09:52 am
|
@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 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!
|
|
|
7475
|
Media / Multimedia / Re: Alternativa a DVDFab
|
en: 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!
|
|
|
7476
|
Media / Multimedia / Re: Alternativa a DVDFab
|
en: 3 Febrero 2014, 08:26 am
|
Siento decirlo, pero, como otro dato cultural, te equivocas, el término correcto es ripear (Ripping): Ripping 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!
|
|
|
7477
|
Sistemas Operativos / Windows / Re: Registro Bloqueado windows 7
|
en: 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
|
|
|
7478
|
Media / Multimedia / Re: Alternativa a DVDFab
|
en: 3 Febrero 2014, 07:49 am
|
Hola
Revivo este post para comentar que por fin encontré la alternativa perfecta al problemático DVDFAB (hasta ayer seguía sin encontrar un software que lo pudiese igualar xD).
Aiseesoft DVD Copy
y
Aiseesoft Blu-Ray Copy
(Luego están los productos "Ripper" y "Converter" de la misma familia, que hacen otras cosas muy distintas...y son los que yo probé en su dia)
Como su nombre indica, obviamente uno trabaja DVD's y el otro BD's, es prácticamente como la característica de copiado del DVDFAB, puedes abrir una carpeta que contenga un DVD/BD, seleccionar la película principal, customizar las pistas de audio, video, y subtitulos que quieres ripear, eliminar el menú de la película ...todo de forma muy cómoda.
...En fin, dos programas muy buenos (y de pago) que funcionan perféctamente en Windows 8.1 sin congelar el PC, a diferencia del DVDFAB.
Un saludo!
|
|
|
7479
|
Programación / Scripting / Re: Ayuda - Leer Caracter por Caracter
|
en: 3 Febrero 2014, 07:03 am
|
como lo ejecuto y le mando estos parametros (archivo y 5) para que los procese? No te lo tomes a mal pero para venir de un lenguaje como C/C++ te veo bastante perezoso para Googlear información básica (el manejo de argumentos en X lenguaje) ~> http://ss64.com/vb/arguments.htmlEntonces deberías reemplazar esta orden: WScript.Echo Caesar("hola",5)
Por esta otra: WScript.StdOut.Write(Caesar(WScript.Arguments(0), WScript.Arguments(1)))
Para llamar al Script y redireccionar la salida del Script a un archivo de texto puedes hacerlo así: Cscript.exe //NoLogo "Caesar.vbs" "hola" 5 > "RESULTADO.TXT"
Como viste en el ejemplo uso un string como parámetro y no un archivo de texto "fuente.txt", la razón es que usar archivos de texto en mi opinión es primitivo, estoy convencido de que podrías trabajar diréctamente con Strings sin necesidad de crear/manipular archivos secundarios en el HDD, de todas formas te muestro los cambios que deberías hacer al Script VBS para tomar un archivo de texto como primer argumento: ' Cojo la primera linea del archivo que le pases como argumento. str = Split(CreateObject("Scripting.FileSystemObject"). _ OpenTextFile(WScript.Arguments(0), 1).ReadAll(), vbnewline)(0) WScript.StdOut.Write(Caesar(str, WScript.Arguments(1)))
En la consola...: Cscript.exe //NoLogo "Caesar.vbs" "FUENTE.TXT" 5 > "RESULTADO.TXT"
Saludos!
|
|
|
|
|
|
|