version 2
This commit is contained in:
@@ -4,43 +4,51 @@ Import-Module -Name 'Windows.Forms'
|
||||
# Creamos una ventana
|
||||
$Form = New-Object Windows.Forms.Form
|
||||
$Form.Text = "Copiador de archivos con Robocopy"
|
||||
$Form.Size = New-Object Drawing.Size(400, 200)
|
||||
$Form.Size = New-Object Drawing.Size(400, 250)
|
||||
|
||||
# Importamos el módulo necesario para crear la interfaz gráfica
|
||||
Import-Module -Name 'Windows.Forms'
|
||||
# Etiqueta y campo de texto para la ruta de origen
|
||||
$LabelSource = New-Object Windows.Forms.Label
|
||||
$LabelSource.Text = "Ruta de origen:"
|
||||
$LabelSource.Location = New-Object Drawing.Point(10, 10)
|
||||
$Form.Controls.Add($LabelSource)
|
||||
|
||||
# Creamos una ventana
|
||||
$Form = New-Object Windows.Forms.Form
|
||||
$Form.Text = "Copiador de archivos con Robocopy"
|
||||
$Form.Size = New-Object Drawing.Size(400, 200)
|
||||
$TextBoxSource = New-Object Windows.Forms.TextBox
|
||||
$TextBoxSource.Location = New-Object Drawing.Point(10, 30)
|
||||
$TextBoxSource.Size = New-Object Drawing.Size(360, 20)
|
||||
$Form.Controls.Add($TextBoxSource)
|
||||
|
||||
# Creamos una etiqueta para mostrar el progreso
|
||||
$Label = New-Object Windows.Forms.Label
|
||||
$Label.Text = "Progreso:"
|
||||
$Label.Location = New-Object Drawing.Point(10, 10)
|
||||
$Form.Controls.Add($Label)
|
||||
# Etiqueta y campo de texto para la ruta de destino
|
||||
$LabelDestination = New-Object Windows.Forms.Label
|
||||
$LabelDestination.Text = "Ruta de destino:"
|
||||
$LabelDestination.Location = New-Object Drawing.Point(10, 60)
|
||||
$Form.Controls.Add($LabelDestination)
|
||||
|
||||
$TextBoxDestination = New-Object Windows.Forms.TextBox
|
||||
$TextBoxDestination.Location = New-Object Drawing.Point(10, 80)
|
||||
$TextBoxDestination.Size = New-Object Drawing.Size(360, 20)
|
||||
$Form.Controls.Add($TextBoxDestination)
|
||||
|
||||
# Creamos una barra de progreso
|
||||
$ProgressBar = New-Object Windows.Forms.ProgressBar
|
||||
$ProgressBar.Location = New-Object Drawing.Point(10, 30)
|
||||
$ProgressBar.Location = New-Object Drawing.Point(10, 110)
|
||||
$ProgressBar.Size = New-Object Drawing.Size(360, 20)
|
||||
$Form.Controls.Add($ProgressBar)
|
||||
|
||||
# Creamos un botón para iniciar la copia
|
||||
$Button = New-Object Windows.Forms.Button
|
||||
$Button.Text = "Iniciar Copia"
|
||||
$Button.Location = New-Object Drawing.Point(10, 60)
|
||||
$Button.Location = New-Object Drawing.Point(10, 140)
|
||||
$Button.Add_Click({
|
||||
# Ruta de origen y destino
|
||||
$SourcePath = "C:\Users\O\Desktop\Origen"
|
||||
$DestinationPath = "C:\Users\O\Desktop\Destino"
|
||||
# Obtenemos las rutas de origen y destino desde los campos de texto
|
||||
$SourcePath = $TextBoxSource.Text
|
||||
$DestinationPath = $TextBoxDestination.Text
|
||||
|
||||
# Ejecutamos Robocopy con los parámetros deseados
|
||||
robocopy $SourcePath $DestinationPath /MIR /Z
|
||||
robocopy $SourcePath $DestinationPath /MIR /Z > $DestinationPath\log.txt
|
||||
|
||||
# Actualizamos la barra de progreso
|
||||
$ProgressBar.Value = 100
|
||||
$Label.Text = "Copia completada"
|
||||
$LabelSource.Text = "Copia completada"
|
||||
})
|
||||
|
||||
$Form.Controls.Add($Button)
|
||||
|
||||
Reference in New Issue
Block a user