-
Notifications
You must be signed in to change notification settings - Fork 4
Update Mysterious-MessyCode.ps1 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
samt441
wants to merge
1
commit into
intellicomp:master
Choose a base branch
from
samt441:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,77 @@ | ||
| $Uninstallers = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*;($Uninstallers|% {$a=$_;Get-ItemProperty -name UninstallString -Path "$($a.name.replace('HKEY_LOCAL_MACHINE','HKLM:'))" -ErrorAction SilentlyContinue|? {(Get-ItemProperty -name DisplayName -Path $a.name.replace('HKEY_LOCAL_MACHINE','HKLM:')).DisplayName -like '*Carbon*'}}).UninstallString | ||
| #set default variables | ||
| $appToUninstall = "keyword" | ||
| $appList = "" | ||
| [Int]$numberOfMatches = 0 | ||
| #prompt for keyword of program to uninstaller if it hasn't been manually changed in the script above | ||
| if ($appToUninstall -eq "keyword"){ | ||
| $appToUninstall = Read-Host "Enter keyword of program you wish to uninstall" | ||
| } | ||
| #create an array of apps from the registry that match the keyword | ||
| function Search-Apps{ | ||
| #path for uninstallers for both 32 and 64 bit programs | ||
| $regPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | ||
| #create an array of uninstallable objects from the registry that contain the supplied keyword | ||
| $global:appList = Get-ChildItem -Path $RegPath | Get-ItemProperty | Where-Object {$_.DisplayName -match $appToUninstall } | ||
| #number of matching programs | ||
| $global:numberOfMatches = $appList.displayName.count | ||
| } | ||
|
|
||
| Search-Apps | ||
|
|
||
| #if there are no matches ask for another keyword | ||
| while($numberOfMatches -eq 0){ | ||
| $appToUninstall = Read-Host "There were no programs that matched the entered keyword. Please enter a new keyword" | ||
| Search-Apps | ||
| } | ||
| #display the number of matching programs | ||
| Write-Output "there are $numberOfMatches installed programs that match" | ||
| #display the list of matching prgrams with thier index value | ||
| $indexLineValue = 0 | ||
| Write-Output $appList.displayName | % {“$indexLineValue $_”;$indexLineValue++} | ||
| #function that uninstalls the programs that are passed in as an array. Silently if possible | ||
| function Uninstall-Program($uninstallList){ | ||
| ForEach ($version in $uninstallList) { | ||
| If ($version.QuuietUninstallString) { | ||
| $uninst = $version.QuuietUninstallString | ||
| Start-Process cmd -ArgumentList "/c $uninst" | ||
| } | ||
| If ($version.UninstallString) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section would run whether there is a quiet uninstall string or not. If there is a quiet string, this would throw an error. |
||
| $uninst = $version.UninstallString | ||
| Start-Process cmd -ArgumentList "/c $uninst /s /q /norestart" -NoNewWindow | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #confirm uninstallation of all programs | ||
| $confirmation = Read-Host "Would you like to uninstall all programs? [y/n]" | ||
| if ($confirmation -eq 'y') { #if confirmed silently uninstall all programs | ||
| Uninstall-Program($appList) | ||
| #verify that the app was uninstalled by searching the registry for it | ||
| Search-Apps | ||
| if ($numberOfMatches -eq 0){ | ||
| Write-Output "$appList.displayName has been successfully uninstalled or the uninstaller has launched" | ||
| }else{ | ||
| Write-Output "An error has occured. Please try again." | ||
| } | ||
| }else { #if you do not want to uninstall all the apps in the list offer to install just one of them | ||
| $confirmation = Read-Host "Would you like to a specific program from the list? [y/n]" | ||
| if ($confirmation -eq 'y') { | ||
| $singleAppToDeleteIndex = Read-Host "enter the number at the beggining of the line of the app you would like to uninstall" | ||
| $singleAppToDelete = $appList[$singleAppToDeleteIndex] | ||
| $confirmation = Read-Host "You have selected to uninstall" $singleAppToDelete.displayName". Proceed? [y/n]" | ||
| if ($confirmation -eq 'y') { | ||
| $deleteAppName = $singleAppToDelete.displayName | ||
| Uninstall-Program($singleAppToDelete) | ||
| Search-Apps | ||
| if ($appList | Where-Object ($_.displayName -eq $deleteAppName)){ | ||
| Write-Output "An error has occured. Please try again." | ||
| }else{ | ||
| Write-Output "$deleteAppName has been successfully uninstalled or the uninstaller has launched" | ||
| } | ||
| }else { #if n was entered in response to the confirmation prompt | ||
| Write-Output "No changes have been made to the system" | ||
| } | ||
| }else { #if n was entered in response to the confirmation prompt | ||
| Write-Output "No changes have been made to the system" | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo here. "Quuiet"