C&C++   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了使用PowerShell 自动安装VC++补丁大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

执行环境:Windows Server 2012 R2

VC++下载链接

 

这里有个问题,说可以静安装,但是未对当前系统检测是否已安装vc++补丁,望大佬指点

 

# 自动安装
Set-ExecutionPolicy -Force remotesigned
# @L_262_3@当前脚本绝对路径
$path = Split-Path -Parent $MyInvocation.MyCommand.DeFinition;
$Net = "\vcredist_x64.exe";
Set-LOCATIOn $path;

function Show-Progress ($file,$arguments){
    $process = start-process $file $arguments -Verb RunAs -PassThru
    for($i = 0; $i -le 100; $i = ($i + 1) % 100)
    {
        Write-Progress -Activity "正在安装 C++补丁" -PercentComplete $i
        Start-Sleep -Milliseconds 100
        if ($process.HasExited) {
            Write-Progress -Activity "Installer" -Completed
            if ($process.HasExited) {
                # 提示安装状态
                if ($process.ExitCode -ne 0) {
                    Write-Warning "安装过程返回错误代码: $($process.ExitCodE)";
                }else {
                    Write-Host "成功安装C++补丁。"
                }
                break
            }
        }
    }
}
function InstallNet ($filepath,$fileName){
    $NetFxPath = $filepath + $filename;
    #验证安装文件是否存在
    If(Test-Path -Path $NetFxPath) {
        Write-Host "正在安装 C++补丁 ..."
        Show-Progress $NetFxPath "/q /norestart"
    }
    Else {
        Write-Warning "找不到C++补丁安装包。"
    }
}
InstallNet $path $Net

大佬总结

以上是大佬教程为你收集整理的使用PowerShell 自动安装VC++补丁全部内容,希望文章能够帮你解决使用PowerShell 自动安装VC++补丁所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。