I have been using the USB Safely Remove command line feature to start and stop an external USB drive. I would start the drive using the return command, run my backup scripts and when done stop the drive.
A week ago I had to replace my backup drive with a larger one. Now when I call the return command a File Explorer window opens up so when I try to stop the drive I get an error because the drive is still in use with by File Explorer.
In Windows Settings I have AutoPlay Enabled and under defaults for removable drive I have selected "Open folder to view files(File Explorer)" so I understand why this is happening but with the old backup drive it didn't open File Explorer even though other USB drives like thumb drives would open File Explorer.
Do you know of a setting that I can assign to the new backup drive to stop this behaviour?
Usually File Explorer doesn't block a drive so perhaps your drive is locked with something else. You can check it by setting "Take no action" in the AutoPlay and repeating your actions with the external drive. It's likely your drive will still be locked. Use the "wholocks" command to see the locking processes.
In any way I can only recommend to use the "forcedstop" command (e.g. usr.exe forcedstop -d G:) in your case that unblocks all connections and safely stops the drive.
thanks for responding. You were right - it was another process blocking the stop command but the wholocks command wasn't much help. It told me that there were 2 processes one blank and one svchost.exe which could be a lot of things.
Anyway, I switched the script to use forcedstop as you suggested and that works.