我正在尝试创建一个.exe文件,该文件将运行一个powershell脚本,安装应用程序的各种组件时必须使用该脚本。我正在执行第1步(共4步)来安装整个应用程序,并希望将其放入一个包中。事情进展得并不顺利。我正在使用f2ko的Ps1到Exe。我在这个软件上找不到任何文档,但它可以做我想做的事情。问题出在打包的文件及其运行方式上。我遇到了几个问题。主要问题似乎与Start-Process有关,当exe正在运行时,我得到一个错误,指出
Start-Process : This command cannot be run completely because the system cannot find all the information required.
At C:\Users\adminjp\AppData\Local\Temp\2605.tml\2606.tmp\2607.ps1:9 char:16错误的其余部分被安装程序的状态栏所掩盖。状态栏运行,但进程不运行。我最初在使用ExecutionPolicy时遇到了一个问题,但为了运行脚本,我手动更改了这个值,解决了这个问题。我在运行这个脚本时遇到了多个问题,而且我还没有读过的在线文章已经用完了。下面是我的powershell脚本:
Set-ExecutionPolicy -Force remotesigned
$NETfile = "env:p2eincfilepath\1 - NDP471-KB4033342-x86-x64-AllOS-ENU.exe"
$NETargs = "/q"
$SQLfile = "env:p2eincfilepath\setup.exe"
$SQLargs = "/ConfigurationFile=`".\ConfigurationFile_SQLExpress.ini`""
function Show-Progress ($file, $arguments, $component){
$process = Start-Process $file $arguments -PassThru
for($i = 0; $i -le 100; $i = ($i + 1) % 100)
{
Write-Progress -Activity "Installer" -PercentComplete $i -Status "Installing $component"
Start-Sleep -Milliseconds 100
if ($process.HasExited) {
Write-Progress -Activity "Installer" -Completed
break
}
}
}
Show-Progress $NETfile $NETargs ".NET 4.7.2"
Show-Progress $SQLfile $SQLargs "SQL Express"将此脚本转换为exe的程序设置解压缩位置,据我所知,我无法设置该位置。附件是他们解释如何引用嵌入文件的屏幕截图:

我使用env:p2eincfilepath是因为它是访问环境变量的powershell方法,而应用程序似乎要创建或使用环境变量。如果您还需要任何其他信息,请告诉我。如果我直接从powershell运行它,并将文件放在根目录中,用./调用它们,那么Ps1似乎可以正常工作。我真的希望继续使用这个函数,因为这给了我状态栏,让用户知道正在安装什么:

发布于 2019-04-25 03:45:13
我认为你需要在环境变量前面有一个$符号来填充它。例如:
$NETfile = "$env:p2eincfilepath\1 - NDP471-KB4033342-x86-x64-AllOS-ENU.exe"
$NETargs = "/q"
$SQLfile = "$env:p2eincfilepath\setup.exe"
$SQLargs = "/ConfigurationFile=`".\ConfigurationFile_SQLExpress.ini`""https://stackoverflow.com/questions/55837110
复制相似问题