One of the ways our app is distributed (on Windows) is as a ZIP archive. Inside this archive is a batch file used for starting the app. The user is supposed to unzip the archive before running our app, but frequently users ignore our instructions and try to run the app without unzipping the archive first. When users do this, the app fails to start, but it's not obvious (to the user) exactly what caused the failure. We'd like to detect from within the batch file whether it's being run from inside a ZIP archive, and if so, show the user a message reminding him to unzip the archive first.
However, it's not clear at all to me how to detect this condition. While the batch variable %cmdcmdline%
contains the command which ran the batch file, there seems to be no way to use the path to reliably tell whether the path points into a ZIP archive. For example, I put the following batch file, named test.bat, into a ZIP archive:
echo %cmdcmdline% pause
The output, when run from within the archive, was:
cmd /c ""C:\Users\liana\AppData\Local\Temp\Temp1_test.zip\test.bat" "
Now, it seems likely that Temp1_test.zip is a ZIP archive, not a real directory, but there's no guarantee that it is. Clearly, Windows knows how to tell the difference, so there must be some more reliable way than simply checking whether ".zip" shows up in the path somewhere. But how?