首页 > 解决方案 > 是否可以在 Windows Powershell 脚本中嵌入 jar 文件?

问题描述

当我有一个 jar( hoge.jar) 文件、一个 unix shell 脚本( hoge.sh) 或一个 windows 批处理文件( hoge.bat) 时,我可以使用下面的 jar 文件获取它们:

cat hoge.sh hoge.jar >foo.sh

或者

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

有没有办法用 powershell 脚本(hoge.ps1

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

至于如上foo.ps1得到的,

java -jar foo.ps1

确实有效,但powerscript的一部分永远不会运行......(当用作powerscript时)

标签: javawindowspowershelljar

解决方案


您可以将任何文件存储在 powershell 脚本中。这是一篇优秀的文章,向您展示了如何使用 base 64 编码。


推荐阅读