Can a script automatically copy or extract files when a disc is inserted?

0
4
Asked By MellowPine42 On

I'm trying to automate a simple Windows task involving an optical disc. When a CD or DVD is inserted, I'd like a file on it to be copied automatically into a specific folder. In another version, the disc would contain a compressed archive—mostly 7-Zip—and the archive would be extracted into that destination folder instead. This would be similar to an installer using autorun, except the goal is only to copy or decompress files. Is this possible, and what kind of script or configuration would be needed?

3 Answers

Answered By QuietHarbor18 On

A more reliable approach is to watch for Windows’ DBT_DEVICEARRIVAL device-notification event, which signals that a disc has been inserted. A small Windows program can respond to that event and then invoke a copy or extraction script. This avoids relying entirely on optical-disc autorun, though the program still needs suitable permissions and should validate the disc contents before doing anything.

Answered By CopperVale7 On

It’s technically possible. An autorun configuration can launch a program, and that program could copy files with a batch or PowerShell script, or run a decompression utility with the appropriate arguments. You’d need to determine the optical drive’s actual drive letter and include—or otherwise have access to—the extraction tool. However, automatic execution from removable media is heavily restricted in modern Windows because it’s a major malware risk, so autorun may be disabled or blocked entirely.

Answered By AmberLattice6 On

Yes, it can be coded, but expect security software or Windows policies to flag or prevent it. Automatically launching programs and writing files as soon as a disc is inserted resembles common malware behavior. In practice, a user-confirmed script or small utility is likely to work more consistently than fully automatic autorun.

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.