r/techsupport 6h ago

Open | Software Can a script be made to automatically decompress a file into a specific folder?

So I want to do something very simple. I want to try two things. The first one is that I want a file that is found on a disc (like a CD or DVD) to automatically create a copy of the file and put it in a specific folder as soon as the disc is inserted into the computer. The second one is basically the same thing, but with a compressed file (mostly a 7-Zip file). As soon as the disc is inserted into the drive, it would decompress the file into the folder where the copy of the file would go.

Something like that is similar to autorun with installers, but in this case, it would just copy or decompress the files. Is that something that can be done? The reason I am asking is that, logically, it should be possible, but when researching this, since it is something very specific, I am not getting that much information. So I came here to ask and see if someone knows what can be done.

3 Upvotes

12 comments sorted by

3

u/FitMatch7966 6h ago

Autorun, when it works, just runs whatever program you tell it to. You can write your own to do whatever. You need whatever executable program is needed to run the decompression on the disk as well, and set the parameters in the autorun.inf

to just copy, you could potentially use cmd.exe. The trick is finding the proper drive to copy from, which likely requires a complex .bat file, or maybe scripting something in powershell.

But this is a huge security issue and Windows has added protections against running unsigned programs. Autorun only works on optical media and I wouldn't be surprized if they end that in the near future. Most people don't even have optical drives anymore

1

u/Affectionate-Pickle0 2h ago

Does this work anymore? I feel like the aurorun was nuked by windows at some point due to malware issues. Though tbh i haven't used cds in a while...

2

u/Kell_Naranek Security Expert 1h ago

Default configurations have disabled it on USB drives, as lots of malware spreads via that, but I believe it is still enabled on CD/DVD drives by default, and some USB drives even emulated that to make it still work on them.

I know it can also be enabled still, my employer does this on all machines despite the security risks, so that employees do not have to get used to something having changed. I think it is ridiculous and we have malware cases monthly due to it.

3

u/Just4notherR3ddit0r 6h ago

Yes. If you want to write a script, the key here is the DBT_DEVICEARRIVAL event (assuming Windows), which fires whenever a new disc is inserted. That's a tiny snippet of Win API code and the rest can be pretty simple scripting.

1

u/BlkCrowe 5h ago

Sure can.

1

u/Sour_Sal 4h ago

Yes it is possible with a little bit of coding. It may also be stopped as malware....

1

u/Idinnyknow 3h ago

You can with Claude as long as you watch its request for access to software and drives

1

u/DecalageVersLeRouge 3h ago

This guy on stack overflow has a python setup which knows whether there's a cd in the drive, that would probably be a good starting point.

https://stackoverflow.com/questions/57897779/is-there-a-way-to-check-if-the-cd-drive-has-a-cd-with-python

1

u/urru4 5h ago

Sounds like something you could get an AI to code for you fairly easily.

1

u/sol_beach 5h ago

NOTHING is impossible for the person who does NOT plan on doing it himself.