Option Explicit Const ForReading = 1 Dim objFso, objFile, objDictionary, objShell Dim sSourcePath 'dossier source où se situe le fichier à sauvegarder Dim sSaveName 'fichier à sauvegarder Dim hostname Dim strPathDestination 'dossier destination où copier le fichier Dim strName, strDicoKey sSourcePath = "C:\Deploy\Webcam" hostname = "D:\hostname.txt" sSaveName= "driver.msi" Set objDictionary = CreateObject("Scripting.Dictionary") Set objFso = CreateObject("Scripting.FileSystemObject") Set objFile = objFso.OpenTextFile(hostname, ForReading) Set objShell = CreateObject("Wscript.Shell") Do Until objFile.AtEndOfStream strName = Trim(objFile.ReadLine) If Not objDictionary.Exists(strName) And Len(strName) > 0 Then objDictionary.Add strName, strName End If Loop objFile.Close For Each strDicoKey in objDictionary.Keys strPathDestination ="\" & strDicoKey & "\C$\emeadts" MsgBox strPathDestination,,"strPathDestination" MsgBox "cmd /k psexec -c -f -high \" & strDicoKey & " c:\deploy\webcam\deploy.cmd " 'objFso.CopyFile sSourcePath & sSaveName, strPathDestination 'objShell.Run "cmd /k psexec -c -f -high \"& strDicoKey &" c:\deploy\webcam\deploy.cmd " Next Set objDictionary = Nothing Set objFile = Nothing Set objFso = Nothing Set objShell = Nothing
Dim objNetwork Dim objFSO Dim sSourcePath 'dossier source où se situe le fichier à sauvagarder Dim sSaveName 'fichier à sauvegarder Dim Hostname 'ressource cible Dim strPathDestination 'dossier destination où copier le fichier Dim objShell Set objFSO =CreateObject("Scripting.FileSystemObject") Set objShell = CreateObject("Wscript.Shell") Const ForReading 1, ForWriting 2, ForAppending = 8 Set H = objFSO.OpenTextFile("c:\Deploy\Webcam\hostname.txt", ForReading) Hostname = H.ReadAll 'quelle fonction pour renvoyer chaque ligne vers la variable Hostame? 'je suppose que je doit créer une boucle ? sSourcePath = "C:\Deploy\Webcam" sSaveName= "driver.msi" strPathDestination ="\" & Hostname & "\C$\emeadts" objFSO.CopyFile sSourcePath & sSaveName, strPathDestination objShell.Run "cmd /k psexec -c -f -high \"& hostname &" c:\deploy\webcam\deploy.cmd " Set ObjFSO= Nothing
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim objNetwork Dim objFSO Dim sSourcePath 'dossier source où se situe le fichier à sauvagarder Dim sSaveName 'fichier à sauvegarder Dim Hostname 'ressource cible Dim strPathDestination 'dossier destination où copier le fichier Dim objShell Hostname=InputBox("Nom de Machine / IP ") Set objShell = CreateObject("Wscript.Shell") sSourcePath = "C:\Deploy\Webcam" sSaveName= "driver.msi" strPathDestination ="\" & Hostname & "\C$\emeadts" Set objFSO =CreateObject("Scripting.FileSystemObject") objFSO.CopyFile sSourcePath & sSaveName, strPathDestination objShell.Run "cmd /k psexec -c -f -high \"& hostname &" c:\deploy\webcam\deploy.cmd " Set ObjFSO= Nothing
dim canal as byte Expected end of statement.