Skip to main content

Uninstall Microsoft VCRedist

Summary

A CW RMM implementation of the Invoke-VcRedistModule agnostic script to uninstall Microsoft Visual C++ Redistributable. By default, the script will uninstall the unsupported redistributable unless a user parameter is set.

Sample Run

Sample Run 1
Sample Run 2
Sample Run 3

Dependencies

This should be a list of ITGlue documents listed in the Related Items sidebar on which this script depends.

  • Agnostic Content Doc Link
  • Custom Field Doc Link
  • etc.

User Parameters

NameExampleRequiredDescription
Release20072007,2008,2012FalseSet the release id(s) of the Redistributable to remove.
All1FalseSetting this parameter to 1 will remove all installed Redistributables from the computer.

User Parameters

Task Creation

Create a new Script Editor style script in the system to implement this Task.

Task Creation 1
Task Creation 2

Name: Uninstall Microsoft VCRedist
Description: Uninstall Microsoft Visual C++ Redistributable
Category: Application

Task Creation 3

Parameters

Add a new parameter by clicking the Add Parameter button present at the top-right corner of the screen.

Add Parameter

This screen will appear.
Parameter Screen

  • Set All in the Parameter Name field.
  • Select Flag from the Parameter Type dropdown menu.
  • Enable the Default Value option.
  • Select False from the Value dropdown menu.
  • Click the Save button.
    Save Parameter

It will ask for confirmation to proceed. Click the Confirm button to create the parameter.
Confirm Parameter

Add another parameter by clicking the Add Parameter button present at the top-right corner of the screen.

Add Parameter

This screen will appear.
Parameter Screen

  • Set Release in the Parameter Name field.
  • Select Text String from the Parameter Type dropdown menu.
  • Click the Save button.
    Save Parameter

It will ask for confirmation to proceed. Click the Confirm button to create the parameter.
Confirm Parameter

Task

Navigate to the Script Editor Section and start by adding a row. You can do this by clicking the Add Row button at the bottom of the script page.

Add Row

A blank function will appear.
Blank Function

Row 1 Function: PowerShell Script

Search and select the PowerShell Script function.

Select PowerShell Script
PowerShell Script Selected

The following function will pop up on the screen:
PowerShell Function

Paste in the following PowerShell script and set the expected time of script execution to 900 seconds. Click the Save button.

#region Setup - Variables
$ProjectName = '@ProjectName@'
[Net.ServicePointManager]::SecurityProtocol = [enum]::ToObject([Net.SecurityProtocolType], 3072)
$BaseURL = 'https://file.provaltech.com/repo'
$PS1URL = "$BaseURL/script/$ProjectName.ps1"
$WorkingDirectory = "C:\ProgramData\_automation\script\Uninstall-VCRedist"
$PS1Path = "$WorkingDirectory\$ProjectName.ps1"
$Workingpath = $WorkingDirectory
$All = '@All@'
$Release = '@Release@'
#endregion
#region Setup - Folder Structure
mkdir -Path $WorkingDirectory -ErrorAction SilentlyContinue | Out-Null
$response = Invoke-WebRequest -Uri $PS1URL -UseBasicParsing
if (($response.StatusCode -ne 200) -and (!(Test-Path -Path $PS1Path))) {
Write-Error -Message "No pre-downloaded script exists and the script '$PS1URL' failed to download. Exiting."
return
} elseif ($response.StatusCode -eq 200) {
Remove-Item -Path $PS1Path -ErrorAction SilentlyContinue
[System.IO.File]::WriteAllLines($PS1Path, $response.Content)
}
if (!(Test-Path -Path $PS1Path)) {
Write-Error -Message 'An error occurred and the script was unable to be downloaded. Exiting.'
return
}
#endregion
#region Execution
if ( $All -and $All -NotMatch 'All' -and $All -Match '1|(Yes)|(True)' ) {
& $PS1Path -Uninstall -All
} elseif ( $Release -and $Release -NotMatch 'Release' -and $Release -match '[0-9]' ) {
& $PS1Path -Uninstall -Release @Release@
} else {
& $PS1Path -Uninstall -Unsupported
}
#endregion

PowerShell Script

Click the Save button at the top-right corner of the screen to save the script.
Save Script

Completed Task

Completed Task

Output

  • Script Log