how to automatically run a batch file when USB drive inserted in Windows 10?

0

I've created an autorun.inf file in my USB drive with the following code:

[autorun] 
open=launch.bat

However, when I connect the USB drive to my PC (running Windows 10), the file launch.bat doesn't run. I wonder it it's possible to run the batch file automatically when I insert the USB or if there is a way to directly run the .exe files I called from the batch file.

Natiya

Posted 2019-08-04T15:34:47.917

Reputation: 179

Question was closed 2019-08-04T16:02:06.387

Difficult to do as this would be an attack vector for malware if Windows allowed it. – Moab – 2019-08-04T15:43:47.717

You have to overcome a lot of security safeguards for this, because it is very easily abused by malware. On recent Windows (7+) you can't even run executables that aren't on a designed set of drives (only C: by default). These was a time where you had to depress [Ctrl] while inserting the USB device to execute autorun.inf. Still true? – xenoid – 2019-08-04T15:44:31.060

AutoRun was disabled by default about 12 years ago. What you want is indeed possible, but any AutoRun device would also start to work both legitimate and malicious – Ramhound – 2019-08-04T15:45:14.070

@xenoid I've tried the Ctrl key while inserting the USB device, but nothing happened. It would be cool if there were some sort of keys' combination to run it :) – Natiya – 2019-08-04T16:21:34.730

@Ramhound you mentioned what I want is possible...how? – Natiya – 2019-08-04T16:22:09.573

It isn't possible due to the fact it's a flash drive. AutoRun was disabled for pretty much everything by default. You have to manually initiate the process in all versions of Windows that are supported. Your question as it's currently written is answered by the duplicate question. I will not return to this question. – Ramhound – 2019-08-04T16:29:27.090

No answers