Can a disc automatically copy or extract files to a specific folder?

August 29, 2026 3 answers
Asked by MellowCactus42
I want to automate two similar tasks on Windows. When a CD or DVD is inserted, I would like a script or program to detect it and either copy a particular file into a chosen folder or extract a compressed archiveโ€”usually a 7-Zip fileโ€”into that folder. This would be similar to an installer launched through autorun, except the goal would only be copying or decompressing files. Is this possible, and what approach would be most practical?

Answers

RiverPixel58
A more reliable approach is to listen for Windows' DBT_DEVICEARRIVAL event, which is triggered when a new disc is inserted. A small Windows program can respond to that event and then call a batch file, PowerShell script, or 7-Zip command to perform the copy or extraction.
Reply to this answer
QuietMarble6
It is technically possible, but automatic file execution from discs is treated as a security risk because the same mechanism could install malware. Windows may block autorun or warn the user, and security software could flag the behavior. If you control the computer, a manually started script or a scheduled, trusted utility is generally safer and more dependable.
Reply to this answer
CopperNoodle7
Yes, this can be done. An autorun configuration can launch a program, batch file, or PowerShell script that copies files. For 7-Zip archives, the disc would need to include either 7-Zip itself or another extraction utility, along with the appropriate command-line options. The script would also need to determine the optical drive letter rather than assuming it is always the same.

VelvetOrchid19: Keep in mind that modern Windows versions restrict automatic execution from removable media, so the user may need to start the script manually or approve it.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions