Identification of the media (USB key or hard disk) on which the script is executed

Good morning

I discovered python 6 months ago but I never got used to it really leaning.

I would like to create a python script that identifies whether it is on USB media (key) or on a computer (hard drive or SSD). I tried several techniques, with the os extension in particular. I never succeeded (however, I managed to identify the operating system, which was a small victory :wink:).

My goal is the following: to succeed in creating a script which, if it is plugged from a USB key onto a computer and executed on it, does not launch, but if it is placed in the computer’s directory then launched, then there he can execute.

Do you have a tutorial on hand explaining how to do it, or even a ready-made script?

Otherwise, if of course the logic of this forum is not to do the work in place of the requesters (which I understand - on my Arduino forum, that’s it…), tell me some avenues to follow to achieve my goals.

Thank you beforehand

[Edited per user’s request to remove personal information — @CAM-Gerlach]

Bonjour Mr.Elliot lol… nywy just kidding
You can think of checking the “absolute paths” which you have said you have tried and you could identify the OS… An overview in windows OS is to check how the path starts like C:/ drive just shows this is a hard drive unless you have partitioned and assigned drive letters to the partition we can assume any other absolute path starting with a different drive letter is an external device… just a thought.
if you are using Linux then check the mounted devices directory if there is a mounted device… check this also
https://www.unix.com/shell-programming-and-scripting/104737-bash-script-detect-list-usb-flash-drives.html

Hello and thank you for your answer

I had already thought about looking at absolute paths, but I want the script to work on all operating systems. So I abandoned this idea, due to lack of knowledge to code a script with this multi-platform technique…

But the way you do it, it seems less complex to implement, so I’m going to tackle it. THANKS :slight_smile:

Also thank you for the link provided, I’ll take a look at that :wink:

Good day

[Edited per user’s request to remove personal information —@CAM-Gerlach]