on microsoft windows, here is a way to do it; without the need to maintain the PID of the API.
perhaps it might be helpful to spark some ideas.
and this gets around the problem mentioned in
"While this does the unmount, it has other quirks, such as I cannot use /B (no window) because then I cannot kill the window"
as you can see here i am using the /b flag
run commands:
start /b rclone.exe mount wasabiwest01:vserver03-bjv.h.vserver03.g.ampe01\ b:\test01\
start /b rclone.exe mount wasabiwest01:vserver03-bjv.h.vserver03.g.ampe01\ b:\test02\
get the stdout of this command:
wmic process where caption="rclone.exe" get processid,commandline
which would look like:
rclone.exe mount wasabiwest01:test01\ b:\test01\ 19364
rclone.exe mount wasabiwest01:test02\ b:\test02\ 5044
and from that output, you can easily determine which rclone.exe to kill.
let's say i want to kill the mount b:\test01\, then I would run this command:
taskkill /pid 19364 /F