Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 在软件安装过程中使用“启动过程”;msiexec.exe“-等等,如何修复错误并继续安装过程?_Powershell - Fatal编程技术网

Powershell 在软件安装过程中使用“启动过程”;msiexec.exe“-等等,如何修复错误并继续安装过程?

Powershell 在软件安装过程中使用“启动过程”;msiexec.exe“-等等,如何修复错误并继续安装过程?,powershell,Powershell,使用PowerShell命令安装“自托管集成运行时软件” 启动进程“msiexec.exe”“/i$path/quiet/passive”-等待,由于“DIAHostService”没有“LocalSystem”访问权限,出现错误。 我有将登录名更改为LocalSystem(“sc.exe config”ServiceName“obj=“LocalSystem”)的代码,但在安装过程中如何做到这一点,如何捕捉错误并进行所需更改并自动继续安装 代码:- param([string]$path, [

使用PowerShell命令安装“自托管集成运行时软件” 启动进程“msiexec.exe”“/i$path/quiet/passive”-等待,由于“DIAHostService”没有“LocalSystem”访问权限,出现错误。 我有将登录名更改为LocalSystem(“sc.exe config”ServiceName“obj=“LocalSystem”)的代码,但在安装过程中如何做到这一点,如何捕捉错误并进行所需更改并自动继续安装

代码:-

param([string]$path, [string]$authKey)
function Install-Gateway([string] $gwPath)
{
    # uninstall any existing gateway
    UnInstall-Gateway

    Write-Host "Start Gateway installation"
    
    Start-Process "msiexec.exe" "/i $path /quiet /passive" -Wait
    Start-Sleep -Seconds 30 

    Write-Host "Succeed to install gateway"
}

因为我无法复制您正在做的事情,所以以这种通用方法为例

param([string]$path, [string]$authKey)
function Install-Gateway([string] $gwPath)
{
    Write-Warning -Message 'Starting Gateway uninstallation'
    UnInstall-Gateway
   
    Try
    {
        'Starting Gateway installation'
        Start-Process -FilePath 'msiexec.exe' -ArgumentList "/i $path /quiet /passive" -Wait -ErrorAction Stop
        Start-Sleep -Seconds 30 
        Write-Verbose -Message 'Gateway installation successful.' -Verbose

    }
    Catch 
    {
        Write-Warning -Message 'AN error occurred'
        $PSItem.Exception.Message
    }
}
如果需要与其他用户一起运行,则需要将运行方式添加为启动进程错误逻辑的一部分。然而,使用RunAs意味着启动一个新的Powershell实例。它不会在同一进程中运行

参考资料

  • 直接-使用环境路径或本地文件夹
  • 调用表达式(IEX)
  • 调用命令(ICM)
  • 第(二)项
  • 接线员&
  • cmd/c-使用旧的cmd shell
  • 启动流程(启动/saps)
  • [Diagnostics.Process]开始()
  • WMI Win32_进程创建()方法
  • 停止分析符号--%
  • 另请参见:

    您还可以考虑在这个用例中使用PowerShell作业


    将其放在脚本或脚本中的函数中,然后使用Try/Catch。这已在函数中。但在执行过程中,控件不会从“启动进程…”命令移动到下一个命令以进行所需的更改。没有暂停选项。您需要显示代码。---这里有完整的代码-或者我如何使用“LocalSystem”帐户运行“启动进程”msiexec.exe“/I$path/quiet/passive”-Wait”。默认情况下,它在NT帐户上运行。如何使用PS命令实现这一点?