简体   繁体   English

如何用exe资源编译批处理文件并在C#中用exe运行它?

[英]How to compile batch file with resources to exe and run it with its exe in C#?

I have batch file and a folder with resources which include one executable file. 我有批处理文件和包含一个可执行文件的资源的文件夹。 This file in its turn uses these resources. 该文件又使用这些资源。 I want to compile these resources (batch file, executable file and folder with resources) to one executable one. 我想将这些资源(批处理文件,可执行文件和带有资源的文件夹)编译为一个可执行文件。 And after launch of this exe, my batch file inside should run with all the ensuing consequences. 在启动此exe之后,我的批处理文件应该运行所有后续的后果。

I'd like to make it on C#. 我想在C#上制作它。 What should I begin with? 我该怎么做?

如果你想完全按照规定这样做,那么一个合理的方法是将你的所有资源打包成一个zip文件,将它作为二进制资源嵌入你的C#可执行文件中,让可执行文件解压缩 资源将文件解压缩到一个临时目录中并使用Process.Create从那里运行它。

@Jon's answer is correct, but you can save yourself the coding entirely - that's what self extractors do. @ Jon的答案是正确的,但你可以完全保存自己的编码 - 这就是自我提取器的作用。 Check out the WinZip Self Extractor for instance. 例如,查看WinZip Self Extractor It can do exactly what you want. 它可以完全按照你的意愿行事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM