Je tente d'automatiser l'extraction d'un ensemble de fichiers compressés (.ARJ) dans différents répertoires.Exécution d'une commande externe à l'aide de chaînes chargées à partir d'un fichier texte
J'utilise actuellement 2 fichiers texte pour stocker 2 bits d'information:
- l'emplacement actuel et le nom des fichiers compressés (ARJFileNames.txt) échantillon - D: _Work_Splunk_TestBed \ Branch00 \ LOAN.ARJ
- l'emplacement cible pour les fichiers à extraire à (ARJFileLocations.txt) échantillon - D: _Work_Splunk_TestBed \ Branch00
Je suis en train d'utiliser la commande WScript.Shell
pour exécuter W inRAR pour extraire les fichiers de leur emplacement actuel vers un emplacement ciblé. Mon problème est quand j'appelle la commande externe de la boucle je ne peux pas sembler obtenir la syntaxe juste pour attacher les chaînes que je tire des dossiers de texte en tandem avec l'appel réellement à WinRar et à son commutateur/commander.
Voici mon code actuel:
'Declaring Constants
Const ForReading = 1, ForWriting = 2, ForAppending = 3
'Declaring Variables
Dim fso, strFilePath, strFileName, fFilePath, fFileName, objShell, WinRAR, strCMD, SevenZip, ARJ
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject ("WScript.shell")
'Open Text Files for use
Set strFilePath = fso.OpenTextFile("D:\_Work\_Splunk\_TestBed\ARJFileLocations.txt", ForReading, TristateFalse)
Set strFileName = fso.OpenTextFile("D:\_Work\_Splunk\_TestBed\ARJFileNames.txt", ForReading, TristateFalse)
Do Until strFilePath.AtEndOfStream
fFilePath = strFilePath.ReadLine 'Get the location of the ARJ file
fFileName = strFileName.ReadLine 'Get the target location for ARJ file contents
'Storing the command as 1 string'
strCMD = "winrar x -y " & " " & fFileName & " " & fFilePath
'Running the command in CLI'
objShell.Run strCMD
Loop
'Cleaning Up
Set strFilePath = Nothing
Set strFileName = Nothing
Set objShl = Nothing