-
Notifications
You must be signed in to change notification settings - Fork 1
/
MSI-extractor.ps1
55 lines (40 loc) · 2.27 KB
/
MSI-extractor.ps1
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# ====================================== #
# Simple MSI Extractor // Source file #
# kernaltrap #
# Version 1.3 #
# This code is licensed under GNU GPL v3 #
# ====================================== #
$version = "1.3r2"
if ($MyInvocation.UnboundArguments.Where({$_ -in '-v'}).Count -ge 1) {
Write-Host "Simple MSI Extractor`nVersion $version`nLicensed under GNU GPL v3"
exit
} else { }
Add-Type -AssemblyName System.Windows.Forms
$Shell = New-Object -ComObject "WScript.Shell" # Setup for Wscript.Shell usage in Powershell
Write-Output ("What MSI do you want me to extract?")
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog -Property @{
InitialDirectory = [Environment]::GetFolderPath('Desktop')
Filter = 'Windows Packages (*.msi)|*.msi'
}
$FileBrowser.ShowDialog() # Display the dialog
# Select output directory
Write-Output ("What folder do you want me to extract the content to?")
$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog -Property @{
Description = 'Select the directory you would like to extract to. Hint: use Make New Folder to organize the install.'
}
$FolderBrowser.ShowDialog()
# ===================================================================== #
# msiexec.exe // Calls the Win32 MSI program #
# /a // Administrative install, passive #
# $FileBrowser.FileName // filename taken from FileBrowser.ShowDialog() #
# TARGETDIR // Use directory taken from FolderBrowser.SelectedPath #
# ===================================================================== #
msiexec.exe /a $FileBrowser.FileName TARGETDIR="$($FolderBrowser.SelectedPath)" /qb
Get-Process | Where-Object{$_.path -eq $path} | Out-Null # Setup for Get-Process, this has a lot of output so it is directed to Out-Null (same as >$null)
# If statement to check if msiexec is running, if not, end the program and display the Shell popup
if(Get-Process | Where-Object{$_.path -eq "C:\Windows\System32\msiexec.exe"}){
Write-Output ("Extracting...")
} else {
Write-Output ("Done! Go to the path you provided to see the contents.")
$Shell.Popup("MSI extracted.", 0, "Thank you for using MSI Extractor", 0)
}