Skip to content

Commit de6b127

Browse files
committed
Create easy install script
1 parent 340d30c commit de6b127

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

MSI-Extractor-InstallScript.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# =================================== #
2+
# Simple MSI Extractor install script #
3+
# kernaltrap #
4+
# Version 1.3 #
5+
# =================================== #
6+
7+
$ImportMSIExtractor = "`nImport-Module $HOME\Documents\PowerShell\Modules\MSI-Extractor.ps1"
8+
$MSIExtractorPath = "$PSScriptRoot/MSI-Extractor.ps1"
9+
10+
if (!(Test-Path -Path $ProfilePath)) {
11+
mkdir $HOME\Documents\PowerShell\Modules | Out-Null
12+
}
13+
14+
if (!(Test-Path -Path $PROFILE.CurrentUserAllHosts)) {
15+
New-Item -Type File -Path $PROFILE.CurrentUserAllHosts -Force
16+
}
17+
18+
if (!(Test-Path -Path $MSIExtractorPath)) {
19+
Throw "MSI-Extractor script is not present in this directory!"
20+
} else {
21+
Copy-Item $PSScriptRoot\MSI-Extractor.ps1 -Destination $HOME\Documents\PowerShell\Modules
22+
}
23+
24+
if (!(Test-Path -Path $ProfilePath)) {
25+
Throw "Cannot find Powershell profile script!"
26+
} else {
27+
Write-Output $ImportMSIExtractor > $PROFILE.CurrentUserAllHosts
28+
Write-Host "All tests passed, MSI-Extractor is installed."
29+
}

MSI-extractor.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ $FolderBrowser.ShowDialog()
3636

3737
msiexec.exe /a $FileBrowser.FileName TARGETDIR="$($FolderBrowser.SelectedPath)" /qb
3838

39-
Get-Process | ?{$_.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)
39+
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)
4040

4141
# If statement to check if msiexec is running, if not, end the program and display the Shell popup
4242

43-
if(Get-Process | ?{$_.path -eq "C:\Windows\System32\msiexec.exe"}){
43+
if(Get-Process | Where-Object{$_.path -eq "C:\Windows\System32\msiexec.exe"}){
4444
Write-Output ("Extracting...")
45-
}else{
45+
} else {
4646
Write-Output ("Done! Go to the path you provided to see the contents.")
4747
$Shell.Popup("MSI extracted.", 0, "Thank you for using MSI Extractor", 0)
4848
}

0 commit comments

Comments
 (0)