0

I want my python file (Stored in my USB drive) to run automatically when USB is connected to my pc

I have tried this

[autorun]
open = MyFiles.py

saved it as "autorun.inf"

But it's not working at all

Sumit
  • 48
  • 7
  • 1
    Other answers may correct me, but I see this as an operating system question rather than a programming one. Also, to autorun an executable when a USB is connected to a computer running a modern OS seems insecure and probably won't be allowed. From [this answer](https://stackoverflow.com/a/54589278/11633985)'s comment, it seems that autoplay for executables (including Python files that would need an interpreter) does not work since WIndows 7. – Thomas May 14 '21 at 08:48

1 Answers1

2

This is not possible on any modern OS. This is due to security concerns. Thus, Autorun is no longer a possibility in Windows. The only way to automatically execute stuff on Windows/Linux/MacOS is to change the registry key on Windows or use a Rubber Ducky.

  • 2
    No, autorun.inf has been disabled as a whole. The only way to enable it is to change the registry key as referenced in my original Answer. CD, DVD, or USB is thus all the same to the operating system. This is why many old game installer CD drives no longer autorun; they were made in a time where Windows would happily autorun anything. – Casey Kuilman May 14 '21 at 09:11