1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Option Explicit
' Avec référence à Wshom.ocx (Windows Script Host Object Model)
Private Sub Command1_Click()
Dim Wsh As WshShell
Set Wsh = New WshShell
'La ligne suivante fonctionne bien mais il faut fermer la console DOS manuellement
Wsh.Run "cmd /k dir c:\ >>c:\test\toto.txt", 5, 1
'La ligne suivante ferme la console DOS mais du coup le fichier est vide....
'Wsh.Run "cmd /k dir c:\ && exit >>c:\test\toto.txt", 5, 1
End Sub
' Sans référence à Wshom.ocx (Windows Script Host Object Model)
Private Sub Command2_Click()
Dim Wsh As Object
Set Wsh = CreateObject("WScript.Shell")
Wsh.Run "cmd /k dir c:\ >>c:\test\toto.txt", 5, 1
End Sub |
Partager