
13/11/2008, 06:55
|
| | Fecha de Ingreso: junio-2006
Mensajes: 166
Antigüedad: 18 años, 10 meses Puntos: 3 | |
ejecutar comandos de dos en vb hola, estoy intentando ejecutar comandos de dos en vb, en especial el comandos systeminfo, que me da la informacion de mi sistema, he hecho esto pero no me muestra nada y tampoco da error.
Private Sub Command1_Click()
txt_resultado.Text = ""
txt_resultado.Text = ejecutar_Dos(Trim(txt_Comando))
End Sub
Private Sub Form_Load()
Command1.Caption = " Ejecutar DOS "
txt_Comando.Text = "c:/documents and settings/administrador.Desktop/systeminfo.exe"
End Sub
Function ejecutar_Dos(Comando As String) As String
Dim oShell As WshShell
Dim oExec As WshExec
Dim ret As String
Set oShell = New WshShell
DoEvents
' ejecutar el comando
Set oExec = oShell.Exec("%comspec% /c " & Comando)
ret = oExec.StdOut.ReadAll()
' retornar la salida y devolverla a la función
ejecutar_Dos = ret ' Replace(ret, Chr(10), vbNewLine)
DoEvents
Me.SetFocus
End Function |