From 375b1bb5013fb6ab018f5ff63fa401158f6aab90 Mon Sep 17 00:00:00 2001 From: Yorick Date: Tue, 18 Oct 2016 12:13:03 +0200 Subject: [PATCH] Reworked modifyShittyRegValue function to create path (and value) than doesn't exist --- cleanW10.ps1 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/cleanW10.ps1 b/cleanW10.ps1 index 49f132d..b14c9fd 100644 --- a/cleanW10.ps1 +++ b/cleanW10.ps1 @@ -71,23 +71,28 @@ function remove_shittyTasks () { # key : key name # value : The value to write function modifyShittyRegValue { - param([string]$path, [string]$key, [string]$value) + param([string]$path, [string]$key, [string]$value, [string]$type) Write-Host -ForegroundColor white -NoNewline "Modify $key reg value to $value :" - try { - Get-ItemPropertyValue -Path $path -Name $key - } - catch { - Write-Host -ForegroundColor Yellow " not Found " - return + if (!(Test-Path $path)){ + Write-Host -ForegroundColor Gray -NoNewline " creating path " + New-Item -Path $path -Force | Out-Null } - try { Set-ItemProperty -Path $path -Name $key -Value $value } + try { + if ($type) { + Set-ItemProperty -Path $path -Name $key -Value $value -Type $type -Force + } + else { + Set-ItemProperty -Path $path -Name $key -Value $value -Force + } + } catch [System.Security.SecurityException]{ Write-Host -ForegroundColor Red "Access denied" return } catch { Write-Host -ForegroundColor Red " Error " + Write-Host $Error[0] return } Write-host -ForegroundColor Green " done " @@ -160,7 +165,7 @@ write-Output "" #$shittyFeatures | foreach { disableShitty $_ } #$shittyServices | Foreach { disableShittyService $_ } #$shittyModernApp | Foreach { disableModernShitty $_ } -$shittyHosts | Foreach { blockShittyHost $HOST_FILE $HOST_IP $_ } +$shittyHosts | Foreach { blockShittyHost $HOST_FILE $HOST_IP $_ } remove_shittyTasks $shittyTasks $shittyIP | Foreach { @@ -187,6 +192,6 @@ modifyShittyRegValue "HKLM:\SOFTWARE\Microsoft\Windows Defender\Spynet" "SpyNetR # Windows Defender Sample Submission modifyShittyRegValue "HKLM:\SOFTWARE\Microsoft\Windows Defender\Spynet" "SubmitSamplesConsent" "0" -#Désinstallation des applications "métro" inutiles +#Désinstallation des applications "métro" inutiles #Get-AppxPackage -AllUsers | Remove-AppxPackage #Get-AppXProvisionedPackage -online | remove-appxprovisionedpackage -online