[英]Self-extracting file that takes arguments and return exitcode
I want to create a self-extracting file (SFX) named Setup.exe which contains a Windows application with some dependencies. 我想创建一个名为Setup.exe的自解压文件(SFX),其中包含带有某些依赖项的Windows应用程序。
It is possible to start the Windows application with arguments, and I would like to put them at my Setup.exe and then it should pass them to the Windows application. 可以使用参数启动Windows应用程序,我想将它们放在我的Setup.exe中,然后它将它们传递给Windows应用程序。 Furtermore, I would like to pass the Windows application exit code to the Setup.exe.
此外,我想将Windows应用程序退出代码传递给Setup.exe。
Currently I have tried to use 7zip, but it seems that it isn't sufficient. 目前,我尝试使用7zip,但似乎还不够。
Is it even possible with 7z or do you know how to do with other tools? 7z甚至有可能还是您知道如何使用其他工具?
You've asked a lot of questions and I am trying to answer a few here, maybe not all of them. 您问了很多问题,我想在这里回答一些问题,也许不是全部。
Yes it is possible to start a Windows Application with arguments. 是的,可以使用参数启动Windows应用程序。 Ideally for that you need to open command prompt and navigate to the directory of your application then type in
theProgramName.exe - arguments options
but that I assume you already know. 理想情况下,您需要打开命令提示符并导航到应用程序的目录,然后键入
theProgramName.exe - arguments options
但我想您已经知道了。
Another approach would be to Create ShortCut
for the Program you are targeting and then you can just Right click -> Properties -> and append your arguments to the Target
field. 另一种方法是为您要定位的程序
Create ShortCut
,然后只需右键单击->属性->并将参数附加到Target
字段即可。 Example : C:\\Games\\Counter-Strike\\hl.exe -steam -game cstrike -noforcemparms -noforcemaccel
示例:
C:\\Games\\Counter-Strike\\hl.exe -steam -game cstrike -noforcemparms -noforcemaccel
Another approach that I assume you would want when you are creating a SFX is to create a .bat
(batch) file with the contents being theProgramName.exe - arguments options
and put it in the same directory as your program and set it to run as our main application when it extracts. 我假设在创建SFX时想要的另一种方法是创建一个
.bat
(批处理)文件,其内容为theProgramName.exe - arguments options
,并将其放置在与程序相同的目录中,并将其设置为提取时是我们的主要应用程序。 If you want the exe
and not the bat
you can use some bat to exe conversion tools, there are tons out there. 如果您想要
exe
而不是bat
,则可以使用一些bat到exe转换工具,那里有很多东西。
The best way I can think of is using programs like Advanced Installer . 我能想到的最好方法是使用Advanced Installer之类的程序 。 You can directly make an
msi
or a sfx
and send a shortcut anywhere (more than one) and it could contain arguments you specify just like what I described in the second way. 您可以直接制作一个
msi
或sfx
并在任何地方(多个)发送快捷方式,它可以包含您指定的参数,就像我在第二种方法中所描述的那样。
So yeah that other tool I'd vouch for that will do what I think you want to do is Advanced Installer. 是的,我为之提供的其他工具将执行我认为您想要做的事情,即Advanced Installer。
After some experiments, I changed the implementation so instead of using 7 zip to create a SFX I just embed all I need like *.msp and such as embedded resources in my Windows application. 经过一些实验后,我更改了实现方式,因此不再使用7 zip创建SFX,而是将我需要的所有内容(例如* .msp和诸如嵌入式资源)嵌入到Windows应用程序中。 On that way my arguments and return code worked out of the box.
这样,我的参数和返回代码即开即用。
I used this link to do actual implementation: https://www.telerik.com/blogs/how-to-merge-assemblies-into-wpf-application 我使用此链接进行实际的实现: https : //www.telerik.com/blogs/how-to-merge-assemblies-into-wpf-application
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.