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

0
2
Asked By MellowCactus42 On

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?

3 Answers

Answered By CopperNoodle7 On

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.

Answered By QuietMarble6 On

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.

Answered By RiverPixel58 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.