I have a script for my USB that i need to use on multiple devices, and i want it to auto-eject, and using this method, as long as it has elevated privileges it runs, no issues, no errors, but i check the file explorer and the USB is still in there: p = Popen(["diskpart"], stdin=PIPE) p.stdin.write(b"select disk " + drive_letter.encode() + b"\n") p.stdin.write(b"remove all dismount\n") p.stdin.write(b"exit\n") print(f"Successfully ejected drive {successful_drive_path}.") this is all using sub-process module for python, I know I don't need to do this, but I still want to. I suspect it's due to the code being ran in the usb, so maybe i could, with the bat file i use to run and handle everything, run the ejection code using a self-deleting script in the main disk. Idk just ideas. Continue reading...