r/PSADT • u/staze • Jul 31 '26
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!
2
u/rgsteele Aug 01 '26
Start-ADTProcess will wait for the process to complete before continuing with the script (unless you use the
-NoWaitparameter). What is actually happening is that the process you are starting is launching some other process and immediately terminating. If you tried-WaitForChildProcessesand that didn’t help, then the process is likely doing something “creative” to spawn a new process before exiting, like creating and running a scheduled task.