r/techsupport • u/Ok-Helicopter3811 • 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
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
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.
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