打开Powershell窗口后,SFX安装程序无法运行Powershell脚本

时间:2019-05-30 16:09:53

标签: powershell 7zip

我正在最新的Windows 10中创建一个7zip sfx安装程序,该程序有望运行Powershell脚本。提取完成后,将显示Powershell窗口,但无需执行脚本即可快速关闭。

非常感谢您的帮助!

我尝试使用自签名证书对脚本文件和installer.exe本身进行签名,但是没有运气。

我已将所有问题排查范围的Powershell ExecutionPolicy更改为Unrestricted,但也没有运气

我在sysinternals中使用进程监视器捕获powershell.exe行为,发现在读写c:\ Users \ xxx \ AppData \ Local \ Microsoft \ Windows \ PowerShell \ StartupProfileData-Interactive后,powershell开始退出线程

这是我的7zip sfx的config.txt:

;!@Install@!UTF-8!
Title="Cloud API"
BeginPrompt="Do you want to install Cloud API?"
RunProgram="powershell.exe -NoExit –NoProfile -ExecutionPolicy Bypass -File %%T\\cloud_api\\installer.PS1"
Directory="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\"
;!@InstallEnd@!

我通过以下方式将python文件压缩:

..\\7zr a -sfx7zSD.sfx cloud-api.7z .\\cloud-api -r -y

我希望解压缩后即可执行installer.PS1,但仅运行powershell.exe并迅速退出而根本不运行脚本。

1 个答案:

答案 0 :(得分:0)

解决此问题的第一步是在7zip配置中声明.ps1脚本的完整路径。这样可以确保您正在调用要启动的脚本。