Private Sub Command1_Click()
Dim wshShell As IWshRuntimeLibrary.wshShell
Dim exExec As IWshRuntimeLibrary.WshExec
'instancie un objet shell
Set wshShell = New IWshRuntimeLibrary.wshShell
'crée un objet exécution en ouvrant l'interprêteur
'de commande DOS
Set exExec = wshShell.Exec("cmd")
'exécute la commande dir
exExec.StdIn.WriteLine "dir"
'ferme le canal
exExec.StdIn.Close
'lit toutes les lignes du canal de sortie
strtest = exExec.StdOut.ReadAll
'termine l'exécution
exExec.Terminate
MsgBox strtest
'libère les ressources
Set exExec = Nothing
Set wshShell = Nothing
End Sub