Hola 47, buen dÃa. Aquà te dejo un ejemplo, es muy sencillo pero creo que te ayudará.
Agregar 1 control CommandButton, 1 Label e insertar el siguiente código
Private Sub Command1_Click()
Dim Archivo As String, Archivo2 As String
Dim NumArchivo As Integer
Archivo = "C:\batch.bat"
NumArchivo = FreeFile()
Archivo2 = "C:\ranefi.txt"
Numarchivo2 = FreeFile()
Open Archivo For Output As #NumArchivo
Print #NumArchivo, "@ECHO OFF"
Print #NumArchivo, "CD\"
Print #NumArchivo, "TASKLIST>ranefi.txt"
Close #NumArchivo
Shell Archivo, vbHide
1
If Dir(Archivo2) = "" Then
GoTo 1
Else
Open Archivo2 For Input As #NumArchivo
Do While Not EOF(1)
Line Input #1, Buff
Todo = Todo & Buff & vbCrLf
Loop
Close #1
Label1.Caption = Todo
End If
End Sub
Private Sub Form_Load()
Label1.AutoSize = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Kill "C:\batch.bat"
Kill "C:\ranefi.txt"
End Sub
Espero te sirva. Y por cierto, hay mejores formas de hacerlo. Nos vemos.
PD: Presiona 2 veces el botón para que te muestre los resultados deseados.