[Ayuda] Como puedo pasar un batch a VB 10

Iniciado por sabeeee, 5 Diciembre 2014, 02:47 AM

0 Miembros y 1 Visitante están viendo este tema.

sabeeee


::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.


::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.
"Vengándose, uno iguala a su enemigo; perdonando, uno se muestra superior a él."
Francis Bacon

Eleкtro

#1








sabeeee

#2
Cita de: Eleкtro en  5 Diciembre 2014, 15:37 PM
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:


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í
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:
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
"Vengándose, uno iguala a su enemigo; perdonando, uno se muestra superior a él."
Francis Bacon

Eleкtro

#3
Cita de: sabeeee en  7 Diciembre 2014, 07:06 AMsigo sin entender System.IO.Directory.GetFiles
Código (vbnet) [Seleccionar]

Imports System.IO

Dim files As IEnumerable(Of FileInfo) =
   From filepath As String
   In Directory.GetFiles(".\", "*", SearchOption.AllDirectories)
   Select New FileInfo(filepath)


For Each fInfo As FileInfo In files

   MessageBox.Show(fInfo.FullName)

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!








sabeeee

Cita de: Eleкtro en  7 Diciembre 2014, 10:01 AM
Código (vbnet) [Seleccionar]

Imports System.IO

Dim files As IEnumerable(Of FileInfo) =
   From filepath As String
   In Directory.GetFiles(".\", "*", SearchOption.AllDirectories)
   Select New FileInfo(filepath)


For Each fInfo As FileInfo In files

   MessageBox.Show(fInfo.FullName)

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.
"Vengándose, uno iguala a su enemigo; perdonando, uno se muestra superior a él."
Francis Bacon