2
votes

I am trying to compress folders in a directory using 7-zip command line, but the 7-zip command line execution is not continuing until I manually click on close button because of a warning with some file (WARNING: The process cannot access the file because it is being used by another process).

There are lot of files and error can occur on different file each time. I have looking into the command line help document seems it there are no arguments for ignore warning messages and continue job.

I want to ignore errors/ warning while compressing process. Is there any arguments for ignore that warning/ error and continue?

Here is my code

For Each source In System.IO.Directory.GetDirectories("C:\Users\hacker\AppData\Local\Google\Chrome\User Data\Default")
            Try
                Dim pInfo As New ProcessStartInfo()
                pInfo.FileName = "C:\Program Files\7-Zip\7zG.exe"  '//zip process continuing when i use 7z.exe here
                pInfo.Arguments = "a -t7z " & destination & ".7z" & ControlChars.Quote & source & ControlChars.Quote & " -mx=3"
                Dim p As New Process()
                p.StartInfo = pInfo
                p.Start()
                p.WaitForExit()
                Dim exitCode = p.ExitCode
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Next

enter image description here

1

1 Answers

0
votes

Can you share your destination folder value, zipping to the the same location as the read location (source) maybe the cause. (I'm posting as an answer since I can't comment yet)

*Just a thought maybe Chrome process is running while having exclusive write permissions to this folder and 7zip read permission collide.

Using the Resource Monitor might assist in searching for open handles to files by process in case this is the problem.