简体   繁体   English

是否可以在 Windows Powershell 脚本中嵌入 jar 文件?

[英]Is it possible to embed a jar file in a Windows Powershell script?

When I have a jar( hoge.jar ) file, and a unix shell script( hoge.sh ) or a windows batch file( hoge.bat ), I can obtain ones with the jar file like below: When I have a jar( hoge.jar ) file, and a unix shell script( hoge.sh ) or a windows batch file( hoge.bat ), I can obtain ones with the jar file like below:

cat hoge.sh hoge.jar >foo.sh

or或者

copy /b hoge.bat+hoge.jar foo.bat

Is there any way to do that with a powershell script ( hoge.ps1 )有没有办法用 powershell 脚本( hoge.ps1 )做到这一点

copy /b hoge.ps1+hoge.jar foo.ps1

As for the foo.ps1 obtained as above,至于如上得到的foo.ps1

java -jar foo.ps1

does work, but the part of the powerscript never runs... (when used as the powerscript ofcourse)确实有效,但powerscript的一部分永远不会运行......(当用作powerscript时)

You can potentially store any file in a powershell script.您可以将任何文件存储在 powershell 脚本中。 Here is an excellent article that shows you how to do so with base 64 encoding.这是一篇优秀的文章,向您展示了如何使用 base 64 编码。

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

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