如何为 Windows 创建一个强大的、最小的安装程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1074013/
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
How to create a robust, minimal installer for Windows?
提问by Mat
I want to create an installer EXE with some specific properties:
我想创建一个具有某些特定属性的安装程序 EXE:
- it should be a single exe file
- it should be robust (i.e. the technique should be known to work well on any Windows system)
- it should create only a single file (a .scn screensaver file) in %systemroot%
- it should add the option to uninstall that particular file in "Control Panel -> Add or Remove Programs" but without creating any new entry
C:\Program Files
or copying an uninstaller.exe somewhere.
- 它应该是一个单独的 exe 文件
- 它应该是健壮的(即应该知道该技术在任何 Windows 系统上都能很好地工作)
- 它应该只在 %systemroot% 中创建一个文件(一个 .scn 屏幕保护程序文件)
- 它应该在“控制面板-> 添加或删除程序”中添加卸载该特定文件的选项,但不创建任何新条目
C:\Program Files
或在某处复制uninstaller.exe。
I've seen installers that work like that - so how to do this?
我见过这样工作的安装程序 - 那么如何做到这一点?
采纳答案by Rob
As you've said it can be an MSI, I'd suggest going down that route.
正如你所说,它可以是一个 MSI,我建议走这条路。
You could play around with installer projects in Visual Studio (if you have it; I'm not sure if the Express editions support making installers), as they'll quite happily produce an MSI that will do what you're asking. It's worth noting they'll produce an EXE and an MSI, you only need to distribute the MSI though.
您可以在 Visual Studio 中尝试安装程序项目(如果有的话;我不确定 Express 版本是否支持制作安装程序),因为它们会很高兴地生成一个 MSI 来满足您的要求。值得注意的是,他们会生成一个 EXE 和一个 MSI,不过您只需要分发 MSI。
Failing that, take a look at Windows Installer XML (WiX)as that will let you hand sculpt an MSI that does exactly what you want it to do and will cater for all five of your points above.
如果做不到这一点,请查看Windows Installer XML (WiX),因为它可以让您手工雕刻一个 MSI,它完全符合您的要求,并且可以满足上述所有五点要求。
Note: Using an MSI will mean that you'll need to have Windows Installer on the machine you're installing to - It's in-box from Windows 2000/ME upwards.
注意:使用 MSI 意味着您需要在要安装到的机器上安装 Windows Installer - 从 Windows 2000/ME 开始,它是内置的。
回答by Otávio Décio
回答by MarkJ
I've heard good things about the free installer Innosetup, and the website says it can create single EXE installs.
我听说过免费安装程序Innosetup 的好消息,网站说它可以创建单个 EXE 安装。
回答by Martin
Try Advanced Installer, I think it can do all that you ask. I use it for slightly more complex installers but the free version is easy to use and powerful.
尝试Advanced Installer,我认为它可以满足您的所有要求。我将它用于稍微复杂的安装程序,但免费版本易于使用且功能强大。
There can be an issue with MSI files, older PCs don't have the latest Windows Installer, 3.1, so you need to install that or prompt the user to, first! Have you looked into using IExpressif you just want to copy a file across?
MSI 文件可能存在问题,较旧的 PC 没有最新的 Windows Installer 3.1,因此您需要先安装它或提示用户安装!如果您只想复制文件,您是否考虑过使用IExpress?
回答by MineCMD
IExpress
速卖通
You can use Microsoft Windows's built in installer wizard called "Iexpress". To access that, open "Run", which is done by hitting Windows Key and R at the same time(WindowsKey+R). When you get in "Run", type in the little box "iexpress.exe". Then hit enter. You are there!
您可以使用 Microsoft Windows 的内置安装程序向导,称为“Iexpress”。要访问它,请打开“运行”,这是通过同时按下 Windows 键和 R 来完成的(Windows 键 + R)。当你进入“运行”时,在小框中输入“iexpress.exe”。然后按回车。你在那里!
Notes:Only available on Microsoft Windows (Legit, and NonLegit)
注意:仅适用于 Microsoft Windows(合法和非合法)
Setup Explained:
Page 1
- Create a Self Extraction Directive file.
Makes a new installation file
- Create a Self Extraction Directive file.
Edits a .SED
file
Page 2(Of Create a Self Extraction Directive file.)
- Look in the "Description" at the bottom
Page 3
- Package Title
The name of your installer, as displayed at the top
Page 4
- Confirmation Prompt
What to tell the user before installing
Page 5
- License Agreement
Skip if you don't know what this is
Page 6
- Packaged Files
What files you need to install
Page 7
- Show Window
How the window is displayed
Page 8
- Displayed At Top
Page 9
- Package Names and Options
Where to save your File
- Hide File Extracting Progress From User
Hides the animation
- Store File using Long Name inside installer
Ignore if you don't know what this is
Page 10
- Displayed At Top
You are done!
Click on the Title to download the file, without doing those instructions. If it is a virus, got infected or you think it is a virus, feel free to delete the file.
设置说明:
第 1 页
- 创建自解压指令文件。
制作一个新的安装文件
- 创建一个自解压指令文件。
编辑.SED
文件
第 2 页(创建自解压指令文件。)
- 查看底部的“描述”
第 3 页
- 包标题
安装程序的名称,如顶部所示
第 4 页
- 确认提示
告诉您什么用户安装前
第 5 页
- 许可协议
如果您不知道这是什么,请跳过
第 6 页
- 打包
文件 您需要安装哪些文件
第 7 页
- 显示窗口 窗口的显示方式
第 8 页
- 显示在首页
9
- 包名称和选项 保存文件的位置 - 隐藏用户的文件提取进度 隐藏动画 - 在安装程序中使用长名称存储文件 如果不这样做,请忽略知道这是什么
第 10 页
- 显示在顶部
您已完成!
单击标题下载文件,无需执行这些说明。如果它是病毒、被感染或您认为它是病毒,请随时删除该文件。
回答by justadreamer
Both NSISand Inno Setupwill cope with all the tasks specified. Inno Setup uses a Pascal-like language for its scripts, NSIS uses its own script language.
无论NSIS和创新安装将应付所有指定的任务。Inno Setup 的脚本使用类似 Pascal 的语言,NSIS 使用它自己的脚本语言。
回答by Ape-inago
The not copying an installer somewhereand adding an entry into Add/Removeseem to be counteractive. My understanding is that add-remove programs neccesarily references a copy of the uninstaller that resides in a Windows directory (so it doesn't lose access to it).
该不是复制一个安装程序的某个地方,并添加进入添加/删除似乎是反作用。我的理解是,添加-删除程序必须引用驻留在 Windows 目录中的卸载程序的副本(因此它不会失去对它的访问权限)。
Perhaps you could have the screensaver double as an uninstaller if you pass it some sort of command-line option. Then simply tell the msi that the uninstaller IS the screensaver (hence no unnecessary coping to some other directory.)
如果您向它传递某种命令行选项,也许您可以让屏幕保护程序兼作卸载程序。然后只需告诉 msi 卸载程序是屏幕保护程序(因此无需处理其他目录。)
回答by Nikhil
NSIS is the way to go, very simple to learn, just write a simple file specifying which files you want to install over where. You can also add QuickLaunch options and so on. Then run the NSIS compiler and you get the exe.
NSIS 是要走的路,学习起来非常简单,只需编写一个简单的文件,指定要安装的文件的位置。您还可以添加 QuickLaunch 选项等。然后运行 NSIS 编译器并获得 exe。
回答by Nikhil
You can create a single installer file using just Visual Studio 2017 Pro and Windows in 3 steps:
您可以通过 3 个步骤仅使用 Visual Studio 2017 Pro 和 Windows 创建单个安装程序文件:
- To have an entry in the Add/Remove Programs, you need to have a setup project.
- The setup project may compile into 2 files: *.msi and setup.exe
- To create a self-extracting package, you can use the IExpress tool
- 要在“添加/删除程序”中有一个条目,您需要有一个安装项目。
- 安装项目可能会编译成 2 个文件:*.msi 和 setup.exe
- 要创建自解压包,可以使用 IExpress 工具
回答by William Leara
InstallShield has a release option called "Single .EXE". It can bundle the payload inside, plug register w/Add-Remove Programs as you specified.
InstallShield 有一个名为“Single .EXE”的发布选项。它可以将有效负载捆绑在内部,根据您的指定插入带有添加-删除程序的寄存器。