Bonjour,

J'ai un script dont la fonctionnalité est la suivante :

1°) Je vérifie si le processus "ftp.exe" tourne sur le serveur. Si elle tourne, je tue le processus car autrement cela plante ma tâche planifiée.
2°) Je transfert des fichiers via ftp par une commande Windows cmd /c à l'aide d'un fichier de commande FTP et j'envoie le résultat dans un fichier log.
3°) Je copie les fichiers transférés dans un autre dossier (Lorsque mon problème FTP sera résolu, je déplacerai les fichiers au lieu de les copier).

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
 
set objWMIService = GetObject ("winmgmts:")
foundProc = False
procName = "ftp.exe"
 
for each Process in objWMIService.InstancesOf ("Win32_Process")
    If StrComp(Process.Name,procName,vbTextCompare) = 0 then
        foundProc = True
        procID = Process.ProcessId
    End If
Next
If foundProc = True Then
 
    Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" &  procID)
    For Each objProcess in colProcessList    
        objProcess.Terminate()
    Next
    WScript.Sleep(1000) 'Pause avant de relancer le check processus
    Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process where ProcessId =" &  procID)
    If colProcessList.count = 0 Then
	FichierCommandeFTP = "D:\FTP\ftptransf_Test.ftp"
    	FichierLogFTP = "D:\FTP\ftp_Test.log"
        Set WSHShell = CreateObject("WScript.Shell")
	WSHShell.CurrentDirectory = "D:\FTP"
    	WSHShell.Run "cmd /c ftp.exe -in -s:" & FichierCommandeFTP & " >> " & FichierLogFTP, 0 , True
		Dim FSO
		Set FSO = CreateObject("Scripting.FileSystemObject")
		FSO.CopyFile "D:\FTP\Test\*.txt", "D:\FTP\old\Test"
		'FSO.CopyFile "D:\FTP\Envoi\AFD_BL\*.csv", "D:\FTP\old\AFD_BL"
		'FSO.CopyFile "D:\FTP\Envoi\AFD_FAC\*.csv", "D:\FTP\old\AFD_FAC"
    End If
End If
WScript.quit
J'ai testé la commande cmd /c ftp.exe -in -s:FichierCommandeFTP >> FichierLogFTP toute seule et elle ne fonctionne que lorsque le promt est sur "D:\FTP".
Donc mon problème est de modifier le répertoire courant avant de lancer la commande cmd /c ftp.exe.

Merci pour votre aide.