-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.txt
36 lines (32 loc) · 988 Bytes
/
script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Script Variables
$fileLocation = "c:\software\"
$installer = "vc_redist.x64.exe"
$software = "Microsoft Visual C++"
$arguments = "/install /quiet /norestart /VerySilent"
# Check if the software is already installed.
$installed = (`
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | `
where { $_.DisplayName -like "$software*" }) -ne $null
if($installed)
{
Write-Host "'$software' is already installed."
}
else
{
# install software.
Write-Host "Running the '$software' installer..."
Start-Process -FilePath "$fileLocation$installer" `
-ArgumentList "$arguments" -Wait
# Confirm the software was installed.
$installed = (`
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | `
where { $_.DisplayName -like "$software*" }) -ne $null
if($installed)
{
Write-Host "'$software' was successfully installed."
}
else
{
Write-Error "'$software' was not installed."
}
}