mirror of
https://github.com/zoicware/RemoveWindowsAI.git
synced 2025-12-17 15:16:27 +01:00
handle error when edge has never been opened before #82
This commit is contained in:
@@ -275,7 +275,8 @@ function Disable-Registry-Keys {
|
|||||||
#powershell core bug where json that has empty strings will error
|
#powershell core bug where json that has empty strings will error
|
||||||
$jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json
|
$jsonContent = (Get-Content $config).Replace('""', '"_empty"') | ConvertFrom-Json
|
||||||
|
|
||||||
if (($jsonContent.browser | Get-Member -MemberType NoteProperty enabled_labs_experiments) -eq $null) {
|
try {
|
||||||
|
if (($jsonContent.browser | Get-Member -MemberType NoteProperty enabled_labs_experiments -ErrorAction Stop) -eq $null) {
|
||||||
$jsonContent.browser | Add-Member -MemberType NoteProperty -Name enabled_labs_experiments -Value @()
|
$jsonContent.browser | Add-Member -MemberType NoteProperty -Name enabled_labs_experiments -Value @()
|
||||||
}
|
}
|
||||||
$flags = @(
|
$flags = @(
|
||||||
@@ -299,6 +300,12 @@ function Disable-Registry-Keys {
|
|||||||
$newContent = $newContent.replace('"_empty"', '""')
|
$newContent = $newContent.replace('"_empty"', '""')
|
||||||
Set-Content $config -Value $newContent -Encoding UTF8 -Force
|
Set-Content $config -Value $newContent -Encoding UTF8 -Force
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
Write-Status -msg 'Edge Browser has never been opened on this machine unable to set flags...' -errorOutput $true
|
||||||
|
Write-Status -msg 'Open Edge once and run this tweak again' -errorOutput $true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#disable office ai with group policy
|
#disable office ai with group policy
|
||||||
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\office\16.0\common\ai\training\general' /v 'disabletraining' /t REG_DWORD /d @('1', '0')[$revert] /f *>$null
|
Reg.exe add 'HKLM\SOFTWARE\Policies\Microsoft\office\16.0\common\ai\training\general' /v 'disabletraining' /t REG_DWORD /d @('1', '0')[$revert] /f *>$null
|
||||||
|
|||||||
Reference in New Issue
Block a user