dmkirkland Posted September 18, 2018 Share Posted September 18, 2018 So, I'm appealing to the experts once again as I'm at my whit's end. I have written a script that processes different files and folder and creates a backup of those files using the 7za.exe file. The archiving process works perfectly. My cleanup process to remove all but the last 3 copies of the archives also works flawlessly. The issue I'm having is that it seems the script, contrary to what I assumed and hoped, seems to process without stopping. It will start the archiving processes simultaneously even though the commands are on separate lines. This presents a huge problem because the last step in the script is to have it cleanup a Temp folder created at script invocation. That Temp folder seems unable to be deleted because the files in that folder (yes they're totally different folders) seem to be in use when the script exits. I've read that AutoIT is not capable of forking or multi-threading (which now seems untrue). I don't mind the archiving processes running in parallel but if the cleanup process attempts before the archiving is complete and the temp files are ready to remove, the folder is not removed as planned which presents a problem for the cleanup process. Did I miss something with the capabilities of AutoIT in relation to forking or multi threading? Link to comment Share on other sites More sharing options...
JohnMC Posted September 18, 2018 Share Posted September 18, 2018 (edited) If the archiving processes are started simultaneously you should provide an example of how your calling 7za.exe as that's likely where the problem lies. You could probably fix it so that the script it paused until the process finishes with something like RunWait or a loop to check to see if the process with specified ProccessID still exists. If you are using RunWait or a loop to wait for the process to close, It's also possible 7za.exe is starting a separate process and closing the original causing the script to continue although I don't think 7za does this but you should still check. If you do want to run multiple instances of 7za.exe you would have to use the Run function so the script continues (like it is now from what you say) but keep track of each PID it returns and then create a loop to check that none of the PIDs exist before the script will continue to the cleanup. Also, AutoIT is in fact not capable of forking or multi-threading in the proper sense of it, it is however capable of starting other processes just like you are with 7za.exe, it could also start another process that is itself if you explicitly told it to. If you have files that are locked either the autoit or 7za.exe process are likely still running even if you cant see a terminal or gui, make sure you check task manager. If you still cant figure it out you can use other tools like like Process Explorer to see what process is locking a file https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer Edited September 18, 2018 by JohnMC https://johnscs.com Link to comment Share on other sites More sharing options...
AdamUL Posted September 18, 2018 Share Posted September 18, 2018 Since you didn't post your script, we can only guess. From what you describe, you are using the Run command. as JohnMC mentioned, which allows AutoIt to spawn a process and continue. I would add ProcessWaitClose before you start the cleaning up part of your script. I use this with my backup script that uses robocopy to backup to multiple servers. This will pause the script until all 7za.exe processes do not exist. ProcessWaitClose("7za.exe") Adam 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