windows iexpress 硬编码提取目标文件夹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5384094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iexpress hard-coded extraction destination folder?
提问by Seth
I'm using iexpress to make a self extracting executable. Is there a way I can hard-code an extraction destination folder (preferably into a temp folder somehwere) so as to not have the extraction pop up the "Please type the location where you want to place the extraced file." dialog?
我正在使用 iexpress 制作一个自解压的可执行文件。有没有办法可以对提取目标文件夹(最好是某个临时文件夹)进行硬编码,以免提取弹出“请输入要放置提取文件的位置”。对话?
回答by fission
There's no direct way to do this. (You can see my other answerfor a longer explanation about it.)
没有直接的方法可以做到这一点。(您可以查看我的其他答案以获得更多关于它的解释。)
The easiest solution is to make an IExpress archive that runs an "installation program", which is really just a batch file that copies the extracted files where they're needed.
最简单的解决方案是制作一个运行“安装程序”的 IExpress 存档,它实际上只是一个批处理文件,用于将提取的文件复制到需要的位置。
In IExpress, you'd launch the batch file like: cmd /c persist.bat
. And persist.bat
looks something like:
在IExpress程序,你会启动批处理文件,如:cmd /c persist.bat
。而且persist.bat
看起来是这样的:
@echo off
xcopy /y * "%temp%\persistent\"
del /f "%temp%\persistent\persist.bat"
(The last line is a nicety to hide the fact that you used this batch file to copy the extracted archive.)
(最后一行很好地隐藏了您使用此批处理文件复制提取的存档的事实。)
回答by Rahsas
Yes, this is possible through the use of an .INF file when you select "Extract files and run an installation command". You must set the .INF file as your Install Program and under the DestinationDirs section you would put the path to the directory you want the files to go to. Here is an example of an .INF file:
是的,这可以通过在选择“提取文件并运行安装命令”时使用 .INF 文件来实现。您必须将 .INF 文件设置为您的安装程序,并且在 DestinationDirs 部分下,您可以将路径放置到您希望文件进入的目录中。以下是 .INF 文件的示例:
[version]
signature="$CHICAGO$"
[DefaultInstall]
CopyFiles=install.files
[DestinationDirs]
install.files=-1,"C:\Program Files\MyCustomDir"
[install.files]
MyFile1.txt
MyFile2.bmp
So this sample shows that the installer will install to C:\Program Files\MyCustomDir. The files under the install.files should list all the files you want to copy to that folder. They must be included in your installer when you are selecting the files to add.
因此,此示例显示安装程序将安装到 C:\Program Files\MyCustomDir。install.files 下的文件应列出您要复制到该文件夹的所有文件。当您选择要添加的文件时,它们必须包含在您的安装程序中。