使用PowerShell 自动安装VC++补丁

执行环境:Windows Server 2012 R2

VC++下载链接

 

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

 

# author:lttr <www.cnblogs.com/GoCircle> 
# date:2019-08-09
# 自动安装 Set
-ExecutionPolicy -Force remotesigned # 获取当前脚本绝对路径 $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

 

 

 

转载于:https://www.cnblogs.com/GoCircle/p/11226584.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值