Reworked modifyShittyRegValue function to create path (and value) than doesn't exist

This commit is contained in:
Yorick 2016-10-18 12:13:03 +02:00
parent 278232165e
commit 375b1bb501

View file

@ -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