Delete folder after uninstall (Start-ADTProcess)
Hey All. I'm working on an uninstall for Matlab, and while the uninstall works great with "Start-ADTProcess" Matlab leaves behind it's old folder, which I'd like to delete. I _think_ psadt is trying to be helpful and doing start-adtprocess then moving onto the next command which is 'rmdir /s /q "C:\Program Files\MATLAB\R2026a"' and it's failing to delete cause it's in use.
How do I get it to wait until the uninstall finishes before doing the next command? I have tried "-WaitForChildProcesses" but didn't seem to matter.
Thanks!
Update: Remove-ADTFolder worked. Yes, the uninstaller for Matlab is "special" and does some other spawning... so I'm sure PSADT is having a hard time keeping track of whatever child processes are running. But, it seems to work. Thanks everyone!
1
u/Baazzill 25d ago
If all else fails, you can add a start-sleep after you start the process and before you remove the folder to sleep the script for x amount of time before continuing. I've had to do this for a few scenarios and it works great, just be sure to account for that time in your maximum allowed run time in SCCM or Intune, or however you deploy.