lukedeloosh Posted March 12, 2019 Share Posted March 12, 2019 (edited) Hello world! I'm trying to add to an archive with this AutoIt code: $CompressPath = c:\directory\subdirectory\path_to_files $CmdChange = "cd " & $CompressPath RunWait(@ComSpec & " /c " & $CmdChange, "", @SW_HIDE) $pathZIP = c:\path_to_archive $filename = archive_name.zip $CmdCompress = "7z a " & $pathZIP & "\" & $filename & " .\* -r" RunWait(@ComSpec & " /c " & $CmdCompress, "", @SW_HIDE) This actually adds all of c:\directory to the archive, instead of just the contents of c:\directory\subdirectory\path_to_files, like it 'should'. However, when I try this code in cmd directly, it works correctly, meaning only the contents of c:\directory\subdirectory\path_to_files are added to the archive, and nothing else: cd c:\directory\subdirectory\path_to_files 7z a c:\path_to_archive\archive_name.zip .\* -r Any ideas as to what I'm doing wrong? Edited March 13, 2019 by lukedeloosh Link to comment Share on other sites More sharing options...
Subz Posted March 12, 2019 Share Posted March 12, 2019 (edited) Try: The reason yours fails is that your running two separate cmd processes, you need to combine them like below (untested): Global $sCompressPath = "c:\directory\subdirectory\path_to_files" Global $sZipPath = "c:\path_to_archive" Global $sZipName = "archive_name.zip" $CmdChange = RunWait(@ComSpec & " /c cd " & $sCompressPath & "&&7z a " & $sZipPath & "\" & $sZipName & " .\* -r", "", @SW_HIDE) Edited March 14, 2019 by Subz lukedeloosh 1 Link to comment Share on other sites More sharing options...
lukedeloosh Posted March 13, 2019 Author Share Posted March 13, 2019 Thanks Subz! Added the 'RunWait' function as it looks like you forgot it. Then it worked beautifully! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now