-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+9.04 KB
...ey-preinstaller-checks.extension/chocolatey-preinstaller-checks.extension.0.0.1-pre.nupkg
Binary file not shown.
38 changes: 38 additions & 0 deletions
38
chocolatey-preinstaller-checks.extension/chocolatey-preinstaller-checks.extension.nuspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. --> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
<metadata> | ||
<id>chocolatey-preinstaller-checks.extension</id> | ||
<version>0.0.1-pre</version> | ||
<owners>bcurran3</owners> | ||
<packageSourceUrl>https://github.com/bcurran3/ChocolateyPackages/tree/master/chocolatey-preinstaller-checks.extension</packageSourceUrl> | ||
<title>Chocolatey Preinstaller Checks Extension</title> | ||
<authors>Bill Curran</authors> | ||
<projectUrl>https://github.com/bcurran3/ChocolateyPackages/tree/master/chocolatey-preinstaller-checks.extension</projectUrl> | ||
<iconUrl>https://raw.githubusercontent.com/bcurran3/ChocolateyPackages/master/chocolatey-preinstaller-checks.extension_icon.png</iconUrl> | ||
<copyright>public domain</copyright> | ||
<licenseUrl>https://wiki.creativecommons.org/wiki/Public_domain</licenseUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<projectSourceUrl>https://github.com/bcurran3/ChocolateyPackages/tree/master/chocolatey-preinstaller-checks.extension</projectSourceUrl> | ||
<bugTrackerUrl>https://github.com/bcurran3/ChocolateyPackages/issues</bugTrackerUrl> | ||
<tags>bcurran3 unofficial choco preinstaller checks extension</tags> | ||
<summary>Chocolatey Preinstaller Checks Extension is a collection of installer add-ons.</summary> | ||
<description> | ||
|
||
#PRERELEASE - TESTING AND FEEDBACK IS HIGHLY ENCOURAGED! | ||
#KNOWN BUG - DOESN'T WORK WITH AUTO UNINSTALLER (YET!) | ||
|
||
##**Chocolatey Preinstaller Checks Extension** is a Chocolatey extension that intercepts and runs checks before installing or uninstalling a program. This extension will start working automatically once installed and does NOT need to be implemented by package creators/maintainers. #**Chocolatey Preinstaller Checks Extension** is meant to be installed and thus used directly by Chocolatey end users. | ||
|
||
###PURPOSE: | ||
**Chocolatey Preinstaller Checks Extension**'s main purpose to fend off specific types of problems before they occur. Currently Chocolatey (choco.exe) is not multi-instance friendly. If you try to install packages using choco install or cinst in two Command Prompts at the same time, strange things may occur. **Chocolatey Preinstaller Checks Extension** avoids these strange things by intercepting calls to install programs and making choco.exe wait for previous instances to finish. **Chocolatey Preinstaller Checks Extension** also checks Windows Installer to see if it's busy and will make MSI installer programs wait until Windows Installer has finished processing the other program. **Chocolatey Preinstaller Checks Extension** will pause and retry until [commandExecutionTimeoutSeconds](https://chocolatey.org/docs/chocolatey-configuration) hits it's threshold of 2700 seconds/45 minutes (default) and then choco will abort. **Chocolatey Preinstaller Checks Extension** only runs before program installations. It does not perform any functions related to portable packages or other choco commands. | ||
|
||
###FEATURES: | ||
* **Chocolatey Preinstaller Checks Extension** will check if there is a pending reboot and warn you about it if so. | ||
* **Chocolatey Preinstaller Checks Extension** will check if there are instances of choco.exe already running and wait for them to finish. | ||
* **Chocolatey Preinstaller Checks Extension** will check if Windows Installer is already running and wait for it to finish. | ||
|
||
**[PACKAGE NOTES](https://github.com/bcurran3/ChocolateyPackages/blob/master/chocolatey-preinstaller-checks.extension/readme.md)** | ||
</description> | ||
</metadata> | ||
</package> |
Binary file added
BIN
+24.5 KB
...preinstaller-checks.extension/chocolatey-preinstaller-checks.extension_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.2 KB
...taller-checks.extension/chocolatey-preinstaller-checks.extension_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions
15
...ey-preinstaller-checks.extension/extensions/Chocolatey-Preinstaller-Checks.extension.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$scriptRoot = Split-Path -Path $MyInvocation.MyCommand.Definition | ||
|
||
$publicFunctions = @( | ||
'Get-chocoStatus', | ||
'Get-PendingRebootStatus', | ||
'Get-WindowsInstallerStatus', | ||
'Start-PreinstallChecks', | ||
'Start-PreuninstallChecks' | ||
) | ||
|
||
Get-ChildItem -Path "$scriptRoot\*.ps1" | ForEach-Object { . $_ } | ||
Export-ModuleMember -Function $publicFunctions | ||
|
||
Set-Alias Install-ChocolateyInstallPackage Start-PreinstallChecks -Force -Scope Global | ||
Set-Alias Uninstall-ChocolateyPackage Start-PreuninstallChecks -Force -Scope Global |
15 changes: 15 additions & 0 deletions
15
chocolatey-preinstaller-checks.extension/extensions/Get-PendingRebootStatus.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function Get-PendingRebootStatus{ | ||
# thanks http://ilovepowershell.com/2015/09/10/how-to-check-if-a-server-needs-a-reboot/ | ||
if (Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -ErrorAction SilentlyContinue) { return $true } | ||
if (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -ErrorAction SilentlyContinue) { return $true } | ||
if (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name PendingFileRenameOperations -ErrorAction SilentlyContinue) { return $true } | ||
try { | ||
$util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities" | ||
$status = $util.DetermineIfRebootPending() | ||
if(($status -ne $null) -and $status.RebootPending){ | ||
return $true | ||
} | ||
}catch{} | ||
|
||
return $false | ||
} |
16 changes: 16 additions & 0 deletions
16
chocolatey-preinstaller-checks.extension/extensions/Get-WindowsInstallerStatus.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function Get-WindowsInstallerStatus{ | ||
$msiexecInstances = @(Get-Process -ea silentlycontinue msiexec).count | ||
# From my observations, msiexec sticks around after a .msi is run. Running a .msi causes 2-3 occurrences of msiexec. | ||
|
||
if ($msiexecInstances -gt 1) | ||
{ | ||
while ($msiexecInstances -gt 1) | ||
{ | ||
Write-Host " ** WARNING: Windows Installer IS currently running. Pausing 30 seconds..." -foreground red | ||
Start-Sleep -seconds 30 | ||
$msiexecInstances = @(Get-Process -ea silentlycontinue msiexec).count | ||
} | ||
} | ||
Write-Host " ** Windows Installer IS NOT currently running" -foreground green | ||
} | ||
|
19 changes: 19 additions & 0 deletions
19
chocolatey-preinstaller-checks.extension/extensions/Get-chocoStatus.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function Get-chocoStatus($AllowedChocos){ | ||
$chocoInstances = @(Get-Process -ea silentlycontinue choco).count | ||
# running choco got you here and is one instance! | ||
# install causes one instance | ||
# uninstall seems to always cause two instances | ||
|
||
if ($chocoInstances -gt $AllowedChocos) | ||
{ | ||
while ($chocoInstances -gt $AllowedChocos) | ||
{ | ||
Write-Host " ** WARNING: Found multiple instances of choco.exe running. Pausing 30 seconds..." -foreground red | ||
Start-Sleep -seconds 30 | ||
$chocoInstances = @(Get-Process -ea silentlycontinue choco).count | ||
} | ||
} | ||
Write-Host " ** choco.exe IS NOT running multiple instances." -foreground green | ||
} | ||
|
||
|
14 changes: 14 additions & 0 deletions
14
chocolatey-preinstaller-checks.extension/extensions/Start-PreinstallChecks.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function Start-PreInstallChecks{ | ||
|
||
Write-Host "PRE-INSTALLATION CHECKS:" -foreground magenta | ||
if (Get-PendingRebootStatus) | ||
{ | ||
Write-Host " ** WARNING: Pending reboot found." -foreground red | ||
} else { | ||
Write-Host " ** Pending reboot NOT found." -foreground green | ||
} | ||
Get-WindowsInstallerStatus | ||
Get-chocoStatus 1 | ||
Remove-Item alias:\Install-ChocolateyInstallPackage | ||
Install-ChocolateyInstallPackage @args | ||
} |
14 changes: 14 additions & 0 deletions
14
chocolatey-preinstaller-checks.extension/extensions/Start-PreuninstallChecks.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function Start-PreuninstallChecks{ | ||
|
||
Write-Host "PRE-UNINSTALLATION CHECKS:" -foreground magenta | ||
if (Get-PendingRebootStatus) | ||
{ | ||
Write-Host " ** WARNING: Pending reboot found." -foreground red | ||
} else { | ||
Write-Host " ** Pending reboot NOT found." -foreground green | ||
} | ||
Get-WindowsInstallerStatus | ||
Get-chocoStatus 2 | ||
Remove-Item alias:\Uninstall-ChocolateyPackage | ||
Uninstall-ChocolateyPackage @args | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@echo off | ||
choco uninstall chocolatey-preinstaller-checks.extension | ||
cpack | ||
cinst chocolatey-preinstaller-checks.extension.0.0.1-pre.nupkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**BCURRAN3'S PACKAGE NOTES:** | ||
|
||
* A BCURRAN3 original! | ||
* I personally use and endorse this extension. | ||
|
||
CHANGE LOG: | ||
0.0.1 - initial release | ||
|
||
ROADMAP: | ||
|
||
|
||
Like my [packages](https://chocolatey.org/profiles/bcurran3)? | ||
|
||
Find them useful? | ||
|
||
**Want to buy me a beer?** | ||
|
||
https://www.paypal.me/bcurran3donations | ||
|
||
If applicable, please always consider donating to the developer or purchasing the software first - this includes Chocolatey licensed editions. | ||
|
||
|
||
|