asheroto / winget-install

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2019/2022.
https://bit.ly/winget-install
GNU General Public License v3.0
272 stars 33 forks source link

[Request]: 2019 don't install VSRedist if already installed #44

Closed o-l-a-v closed 4 months ago

o-l-a-v commented 4 months ago

Describe the feature or improvement you're requesting

For Windows Server 2019: Don't download and install VCRedist if already installed.

https://github.com/asheroto/winget-install/blob/958f61fde5291c35943e0236895e49aafa99637d/winget-install.ps1#L872-L890

Additional context

Some ways to detect whether required VCRedist is installed:

# Assets
$64BitOS = [System.Environment]::Is64BitOperatingSystem
$64BitProcess = [System.Environment]::Is64BitProcess

# Require running system native process
if ($64BitOS -and -not $64BitProcess) {
    Throw 'Please run PowerShell in the systen native architecture (x64 PowerShell if x64 Windows).'
}

# Check that uninstall information exists in the registry
Test-Path -Path (
    [string]::Format(
        'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\{0}\Microsoft\VisualStudio\14.0\VC\Runtimes\X{1}',
        $(if($64BitOS -and $64BitProcess){'WOW6432Node\'}),
        $(if($64BitOS){'64'}else{'86'})
    )
)

# Check that one required DLL exists on the file system
[System.IO.File]::Exists(
    [string]::Format(
        '{0}\system32\concrt140.dll',
        $env:windir
    )
)

I've done something similar with my WinGet + Intune R'n'D project:

asheroto commented 4 months ago

This is excellent! Adding it in 4.1.1. Thanks!

asheroto commented 4 months ago

Gave you credit at the top. 😊 Will be releasing a new version soon.

https://github.com/asheroto/winget-install/blob/master/winget-install.ps1