
$url = "https://download.microsoft.com/download/8/4/A/84A35BF1-DAFE-4AE8-82AF-AD2AE20B6B14/directx_Jun2010_redist.exe"

$folder = "C:\AOFG\DirectX"
$executable = "$folder\dxwebsetup.exe"
New-Item -Path $folder -ItemType Directory| Out-Null

(New-Object System.Net.WebClient).DownloadFile($url, $executable)

$7zpath = Get-ItemProperty -path  HKLM:\SOFTWARE\7-Zip\ -Name Path
$7zpath = $7zpath.Path
$7zpathexe = $7zpath + "7z.exe"

# Extracting setup files
$filesToExtract = "*"
Start-Process -FilePath $7zpathexe -NoNewWindow -ArgumentList "x -bso0 -bsp1 -bse1 -aoa $executable $filesToExtract -o""$folder""" -Wait

Start-Process -FilePath "$folder\DXSETUP.exe" -ArgumentList "/silent" -Wait
