Bonjour,
Je voudrais lancer des commandes dos lues séquentiellement dans un fichier texte. Je voudrais tester que la commande dos soit terminée avant de lancer la suivante.
J'ai essayé le script de la FAQ qui attend que l'on ferme notepad pour continuer, mais quand je remplace "notepad" par une variable j'ai le message d'erreur: 'Type d'argument Byref incompatible'
Voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 Sub Main() Dim fic As String Dim xx fic = "c:\zzz.txt" If Dir(fic, vbHidden) <> "" Then Dim numfich Dim ligne As String numfich = FreeFile Open fic For Input As #numfich While Not EOF(numfich) Line Input #numfich, ligne prog = "command.com /c " & ligne xx = process(prog) Wend Close #numfich End If End Sub Function process(prog) Dim proc As PROCESS_INFORMATION On Error GoTo errortag proc.hProcess = -1 proc.hThread = -1 Call LancerProcess(prog, proc) ' Dans le cript original c'est : Call LancerProcess("notepad", proc) Call AttendreFinProcess(proc) Call CloseHandle(proc.hProcess) Call CloseHandle(proc.hThread) Exit Function errortag: If proc.hProcess <> -1 Then CloseHandle proc.hProcess If proc.hThread <> -1 Then CloseHandle proc.hThread MsgBox Err.Number & " - " & Err.Description End Function
Quelqu'un peut t'il m'aider ?
Partager