Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: sabeeee en 5 Diciembre 2014, 02:47 am



Título: [Ayuda] Como puedo pasar un batch a VB 10
Publicado por: sabeeee en 5 Diciembre 2014, 02:47 am
Código:
::Sistema de UPX::
::Variables::
::Configuracion de compresion::
set param=--best
::Codigo
for /R %%x in (*.*) do (
upx.exe "%param%" "%%x"
)

O sino ayúdenme a hacer esto nomas, lo de las variables no es tan importante, ya que para el uso que le voy a dar es inútil.

Código:
::Funcionamiento
::Lista todos los archivos de las subcarpetas y los guarda en la variable "%%x"
for /R %%x in (*.*) do (
upx.exe --best "%%x"
)

Ese no es el codigo completo, solo pido una ayuda para empezar por favor.


Título: Re: [Ayuda] Como puedo pasar un batch a VB 10
Publicado por: Eleкtro en 5 Diciembre 2014, 15:37 pm
solo pido una ayuda para empezar

Lo que pretendes hacer es muy sencillo, estoy seguro de que si lees un poco no te costará llevarlo a cabo:

Estos son los métodos que necesitarás utilizar:

  • System.IO.Directory.GetFiles(String, String, SearchOption) - MSDN
    Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.
    (http://msdn.microsoft.com/en-us/library/ms143316%28v=vs.110%29.aspx)
  • System.Diagnostics.Process.Start(String, String) - MSDN
    Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component.
    (http://msdn.microsoft.com/en-us/library/h6ak8zt5%28v=vs.110%29.aspx)

Si tienes dudas, muestra el código con tu progreso, y con gusto te corregiré(mos) el código.

PD: Las dudas sobre VisualBasic.Net, van en la sección de .Net

Saludos!


Título: Re: [Ayuda] Como puedo pasar un batch a VB 10
Publicado por: sabeeee en 7 Diciembre 2014, 07:06 am
Lo que pretendes hacer es muy sencillo, estoy seguro de que si lees un poco no te costará llevarlo a cabo:

Estos son los métodos que necesitarás utilizar:

  • System.IO.Directory.GetFiles(String, String, SearchOption) - MSDN
    Returns the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories.
    (http://msdn.microsoft.com/en-us/library/ms143316%28v=vs.110%29.aspx)
  • System.Diagnostics.Process.Start(String, String) - MSDN
    Starts a process resource by specifying the name of an application and a set of command-line arguments, and associates the resource with a new Process component.
    (http://msdn.microsoft.com/en-us/library/h6ak8zt5%28v=vs.110%29.aspx)

Si tienes dudas, muestra el código con tu progreso, y con gusto te corregiré(mos) el código.

PD: Las dudas sobre VisualBasic.Net, van en la sección de .Net

Saludos!

Gracias.
---
Esto es lo que primero conseguí
Código:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Process.Start("upx.exe", "-d AAC.dll")
    End Sub
End Class

Nuevo:
Código:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
    Friend WithEvents Label1 As System.Windows.Forms.Label

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer. 
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(138, 34)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(40, 13)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Espere"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(336, 102)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "howto_net_start_notepad_wait"
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Activated
        ' Set start information.
        Dim start_info As New ProcessStartInfo("upx.exe", "--best *.*")
        start_info.UseShellExecute = False
        start_info.CreateNoWindow = True

        ' Make the process and set its start information.
        Dim proc As New Process
        proc.StartInfo = start_info

        ' Start the process.
        proc.Start()

        ' Wait until Notepad exits.
        proc.WaitForExit()
        Me.Close()
    End Sub
End Class
Me las arregle con un código que encontré por allí y con unas modificaciones conseguí hacer esto, pero sigo sin entender System.IO.Directory.GetFiles


Título: Re: [Ayuda] Como puedo pasar un batch a VB 10
Publicado por: Eleкtro en 7 Diciembre 2014, 10:01 am
sigo sin entender System.IO.Directory.GetFiles
Código
  1. Imports System.IO
  2.  
  3. Dim files As IEnumerable(Of FileInfo) =
  4.    From filepath As String
  5.    In Directory.GetFiles(".\", "*", SearchOption.AllDirectories)
  6.    Select New FileInfo(filepath)
  7.  
  8.  
  9. For Each fInfo As FileInfo In files
  10.  
  11.    MessageBox.Show(fInfo.FullName)
  12.  
  13. Next fInfo

Como te dije era algo facil, solo queria que leyeses un poco para entenderlo.

EDITO: Recuerda encerrar entre comillas dobles los nombres de archivo que le pases comoa rgumento al proceso, por los espacios en blanco.

saludos!


Título: Re: [Ayuda] Como puedo pasar un batch a VB 10
Publicado por: sabeeee en 7 Diciembre 2014, 22:27 pm
Código
  1. Imports System.IO
  2.  
  3. Dim files As IEnumerable(Of FileInfo) =
  4.    From filepath As String
  5.    In Directory.GetFiles(".\", "*", SearchOption.AllDirectories)
  6.    Select New FileInfo(filepath)
  7.  
  8.  
  9. For Each fInfo As FileInfo In files
  10.  
  11.    MessageBox.Show(fInfo.FullName)
  12.  
  13. Next fInfo

Como te dije era algo facil, solo queria que leyeses un poco para entenderlo.

EDITO: Recuerda encerrar entre comillas dobles los nombres de archivo que le pases comoa rgumento al proceso, por los espacios en blanco.

saludos!

Muchísimas gracias, eternamente agradecidos con ustedes.