# Verificar se esta a executar como Administrador if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Write-Host "AVISO: Este script necessita de privilegios de Administrador." -ForegroundColor Red Write-Host "A tentar reiniciar automaticamente como Administrador..." -ForegroundColor Yellow Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs exit } # Variavel para controlar se deve reiniciar (pode ser alterada pelo utilizador) $skipRestart = $false # Mudar para RemoteSigned para maior seguranca Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force Set-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -Name 'Win11debloat' -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe C:\Windows\System32\jq\Win11debloat.ps1" Write-Host "=== Script de Instalacao de Aplicacoes (Windows 11) ===" -ForegroundColor Cyan Write-Host "" # Create log directory $logDir = "C:\logs" if (-not (Test-Path $logDir)) { $null = New-Item -ItemType Directory -Path $logDir -Force } $logFile = Join-Path $logDir "instalar-aplicacoes-$(Get-Date -Format 'yyyyMMdd-HHmmss').log" Start-Transcript -Path $logFile -Append | Out-Null $regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" New-Item -Path $regPath -Force | Out-Null New-ItemProperty -Path $regPath -Name "StartupBoostEnabled" -Value 0 -PropertyType DWORD -Force | Out-Null New-ItemProperty -Path $regPath -Name "HideFirstRunExperience" -Value 1 -PropertyType DWORD -Force | Out-Null & "C:\Windows\System32\TWEAKS-USER.ps1" & "C:\Windows\System32\TWEAKS-ADMIN.ps1" # ============================================================================== # INÍCIO: TWEAKS-USER.ps1 (atualizado com novos tweaks) # ============================================================================== # ============================================================================== # INTERFACE E EXPLORER # ============================================================================== # Disable "Show more options" context menu (restore classic context menu) if((Test-Path -LiteralPath "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32") -ne $true) { New-Item "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32' -Name '(default)' -Value '' -PropertyType String -Force -ea SilentlyContinue; $Path = "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" # Cria a estrutura de pastas necess ria no Registro New-Item -Path $Path -Force | Out-Null New-Item -Path "$Path\InprocServer32" -Force | Out-Null # Define o valor padr o como vazio (isso o que ativa o menu cl ssico) Set-ItemProperty -Path "$Path\InprocServer32" -Name "(Default)" -Value "" -Force | Out-Null # Show file extensions if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Show drive letters first if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer' -Name 'ShowDriveLettersFirst' -Value 4 -PropertyType DWord -Force -ea SilentlyContinue; # Add Control Panel to Navigation Pane if((Test-Path -LiteralPath "HKCU:\Software\Classes\CLSID\{26EE0668-A00A-44D7-9371-BEB064C98683}") -ne $true) { New-Item "HKCU:\Software\Classes\CLSID\{26EE0668-A00A-44D7-9371-BEB064C98683}" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Classes\CLSID\{26EE0668-A00A-44D7-9371-BEB064C98683}' -Name '(default)' -Value 'Control Panel' -PropertyType String -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Software\Classes\CLSID\{26EE0668-A00A-44D7-9371-BEB064C98683}' -Name 'System.IsPinnedToNameSpaceTree' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Enable icons auto arrange if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\Shell\Bags\1\Desktop") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\Shell\Bags\1\Desktop" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\Shell\Bags\1\Desktop' -Name 'FFlags' -Value 1075839525 -PropertyType DWord -Force -ea SilentlyContinue; # Animation effects if((Test-Path -LiteralPath "HKCU:\Control Panel\Desktop") -ne $true) { New-Item "HKCU:\Control Panel\Desktop" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Desktop' -Name 'UserPreferencesMask' -Value ([byte[]](0x90,0x12,0x03,0x80,0x10,0x00,0x00,0x00)) -PropertyType Binary -Force -ea SilentlyContinue; # Disable Windows 11 Start Menu from opening at first user logon if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'StartShownOnUpgrade' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # BARRA DE TAREFAS E NOTIFICACOES # ============================================================================== # Show battery percentage on taskbar if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'IsBatteryPercentageEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Enable End Task if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDeveloperSettings") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDeveloperSettings" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDeveloperSettings' -Name 'TaskbarEndTask' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Disable sync provider notifications in File Explorer if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowSyncProviderNotifications' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # PRIVACIDADE E TELEMETRIA # ============================================================================== # Disable Cortana $cortanaPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' if (!(Test-Path $cortanaPath)) { New-Item -Path $cortanaPath -Force | Out-Null } Set-ItemProperty -Path $cortanaPath -Name 'AllowCortana' -Value 0 -Type DWord -Force | Out-Null $registryPaths = @( @{Path = "HKCU:\SOFTWARE\Microsoft\Personalization\Settings"; Name = "AcceptedPrivacyPolicy"; Value = 0}, @{Path = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"; Name = "RestrictImplicitTextCollection"; Value = 1}, @{Path = "HKCU:\SOFTWARE\Microsoft\InputPersonalization"; Name = "RestrictImplicitInkCollection"; Value = 1}, @{Path = "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore"; Name = "HarvestContacts"; Value = 0} ) foreach ($regPath in $registryPaths) { if (!(Test-Path $regPath.Path)) { New-Item -Path $regPath.Path -Force | Out-Null } Set-ItemProperty -Path $regPath.Path -Name $regPath.Name -Type DWord -Value $regPath.Value } # Set feedback frequency to "Never" Write-Output "Setting Never Feedback Frequency ..." if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules")) { New-Item -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Force } New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -PropertyType DWord -Value 0 -Force # Disable Advertising ID Write-Output "Disabling Advertising ID ..." if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo")) { New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Force } New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -PropertyType DWord -Value 0 -Force # Disable Windows Tips Write-Output "Disabling Windows Tips ..." New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -PropertyType DWord -Value 0 -Force # Disable "What's New in Windows" Write-Output "Disabling Whats New In Windows ..." if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement")) { New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement" -Force } New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement" -Name "ScoobeSystemSettingEnabled" -PropertyType DWord -Value 0 -Force # Allow apps to use advertising ID if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -force -ea SilentlyContinue }; # Tailored experiences if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Privacy") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Privacy" -force -ea SilentlyContinue }; # Disable Windows welcome experience if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' -Name 'SubscribedContent-310093Enabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # GESTAO DE FICHEIROS # ============================================================================== # Disable block downloaded files if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments' -Name 'SaveZoneInformation' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # LOCALIZACAO E REDE # ============================================================================== # Location (allow) if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location" -force -ea SilentlyContinue }; if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location\NonPackaged") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location\NonPackaged" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location' -Name 'Value' -Value 'Allow' -PropertyType String -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location\NonPackaged' -Name 'Value' -Value 'Allow' -PropertyType String -Force -ea SilentlyContinue; # AutoDetect Proxy if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name 'AutoDetect' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # SISTEMA E DESEMPENHO # ============================================================================== # Disable startup delay if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize' -Name 'Startupdelayinmsec' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize' -Name 'WaitForIdleState' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # PowerShell execution policy if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell") -ne $true) { New-Item "HKCU:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' -Name 'ExecutionPolicy' -Value 'Bypass' -PropertyType String -Force -ea SilentlyContinue; # Enable Windows Script Host Write-Output "Enabling Windows Script Host ..." Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Force -ErrorAction Ignore # Allow user to receive Microsoft Updates if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'AllowMUUpdateService' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # GAMING # ============================================================================== # Disable Game DVR if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR" -force -ea SilentlyContinue }; if((Test-Path -LiteralPath "HKCU:\System\GameConfigStore") -ne $true) { New-Item "HKCU:\System\GameConfigStore" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\GameDVR' -Name 'AppCaptureEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\System\GameConfigStore' -Name 'GameDVR_Enabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Xbox Game Bar tips Write-Output "Disabling Xbox Game Tips ..." if ((Get-AppxPackage -Name Microsoft.XboxGamingOverlay) -or (Get-AppxPackage -Name Microsoft.GamingApp)) { New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\GameBar" -Name "ShowStartupPanel" -PropertyType DWord -Value 0 -Force } # ============================================================================== # ACESSIBILIDADE # ============================================================================== # Disable sticky keys if((Test-Path -LiteralPath "HKCU:\Control Panel\Accessibility\StickyKeys") -ne $true) { New-Item "HKCU:\Control Panel\Accessibility\StickyKeys" -force -ea SilentlyContinue }; if((Test-Path -LiteralPath "HKCU:\Control Panel\Accessibility\Keyboard Response") -ne $true) { New-Item "HKCU:\Control Panel\Accessibility\Keyboard Response" -force -ea SilentlyContinue }; if((Test-Path -LiteralPath "HKCU:\Control Panel\Accessibility\ToggleKeys") -ne $true) { New-Item "HKCU:\Control Panel\Accessibility\ToggleKeys" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Accessibility\StickyKeys' -Name 'Flags' -Value '506' -PropertyType String -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Accessibility\Keyboard Response' -Name 'Flags' -Value '122' -PropertyType String -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Accessibility\ToggleKeys' -Name 'Flags' -Value '58' -PropertyType String -Force -ea SilentlyContinue; # ============================================================================== # TERMINAL # ============================================================================== # Set Windows Terminal as default terminal app Write-Output "Setting Windows Terminal Default Terminal App ..." if (Get-AppxPackage -Name Microsoft.WindowsTerminal) { $TerminalVersion = (Get-AppxPackage -Name Microsoft.WindowsTerminal).Version if ([System.Version]$TerminalVersion -ge [System.Version]"1.11") { if (-not (Test-Path -Path "HKCU:\Console\%%Startup")) { New-Item -Path "HKCU:\Console\%%Startup" -Force } $PackageFullName = (Get-AppxPackage -Name Microsoft.WindowsTerminal).PackageFullName Get-ChildItem -Path "HKLM:\SOFTWARE\Classes\PackagedCom\Package\$PackageFullName\Class" | ForEach-Object { $serverId = Get-ItemPropertyValue -Path $_.PSPath -Name ServerId if ($serverId -eq 0) { New-ItemProperty -Path "HKCU:\Console\%%Startup" -Name "DelegationConsole" -PropertyType String -Value $_.PSChildName -Force } if ($serverId -eq 1) { New-ItemProperty -Path "HKCU:\Console\%%Startup" -Name "DelegationTerminal" -PropertyType String -Value $_.PSChildName -Force } } } } # ============================================================================== # RUNONCE # ============================================================================== # RunOnce placeholder if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce" -force -ea SilentlyContinue }; # ============================================================================== # NOVOS TWEAKS HKCU (do newtweaks.txt) # ============================================================================== # Disable Click To Do (AI overlay) if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\Shell\ClickToDo") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\Shell\ClickToDo" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\Shell\ClickToDo' -Name 'DisableClickToDo' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Edge Hubs Sidebar if((Test-Path -LiteralPath "HKCU:\Software\Policies\Microsoft\Edge") -ne $true) { New-Item "HKCU:\Software\Policies\Microsoft\Edge" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Policies\Microsoft\Edge' -Name 'HubsSidebarEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Narrator Online Services if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Narrator\NoRoam") -ne $true) { New-Item "HKCU:\Software\Microsoft\Narrator\NoRoam" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Narrator\NoRoam' -Name 'OnlineServicesEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Reduce Diagnostic Data (Policy - HKCU) if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Policies\Microsoft\Windows\DataCollection") -ne $true) { New-Item "HKCU:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\DataCollection' -Name 'AllowTelemetry' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Reduce Diagnostic Data (direct - HKCU) if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection") -ne $true) { New-Item "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection' -Name 'AllowTelemetry' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Tailored Experiences (CloudContent - HKCU) if((Test-Path -LiteralPath "HKCU:\Software\Policies\Microsoft\Windows\CloudContent") -ne $true) { New-Item "HKCU:\Software\Policies\Microsoft\Windows\CloudContent" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Policies\Microsoft\Windows\CloudContent' -Name 'DisableTailoredExperiencesWithDiagnosticData' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Online Speech Recognition (HasAccepted) if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy") -ne $true) { New-Item "HKCU:\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy' -Name 'HasAccepted' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Online Speech Recognition (InputPersonalization - HKCU) if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Policies\Microsoft\InputPersonalization") -ne $true) { New-Item "HKCU:\SOFTWARE\Policies\Microsoft\InputPersonalization" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\InputPersonalization' -Name 'AllowInputPersonalization' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # DESATIVAR WIDGETS DO WINDOWS # ============================================================================== # Disable Widgets (taskbar) if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'TaskbarDa' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Widgets (policy - HKLM) $widgetsPolicyPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Dsh' if (!(Test-Path $widgetsPolicyPath)) { New-Item -Path $widgetsPolicyPath -Force | Out-Null } Set-ItemProperty -Path $widgetsPolicyPath -Name 'AllowNewsAndInterests' -Value 0 -Type DWord -Force | Out-Null Set-ItemProperty -Path $widgetsPolicyPath -Name 'AllowWebExperience' -Value 0 -Type DWord -Force | Out-Null # Disable Widgets board auto-open $widgetsPolicyPath2 = 'HKLM:\SOFTWARE\Microsoft\PolicyManager\default\NewsAndInterests\AllowNewsAndInterests' if (!(Test-Path $widgetsPolicyPath2)) { New-Item -Path $widgetsPolicyPath2 -Force | Out-Null } Set-ItemProperty -Path $widgetsPolicyPath2 -Name 'value' -Value 0 -Type DWord -Force | Out-Null # Remove Widgets from taskbar alignment (optional: left taskbar keeps widgets off) if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'TaskbarAl' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue; # ============================================================================== # REMOVER BING DO WINDOWS SEARCH E EDGE # ============================================================================== # Disable Bing Search in Windows Search $searchPolicyPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' if (!(Test-Path $searchPolicyPath)) { New-Item -Path $searchPolicyPath -Force | Out-Null } Set-ItemProperty -Path $searchPolicyPath -Name 'DisableWebSearch' -Value 1 -Type DWord -Force | Out-Null Set-ItemProperty -Path $searchPolicyPath -Name 'ConnectedSearchUseWeb' -Value 0 -Type DWord -Force | Out-Null Set-ItemProperty -Path $searchPolicyPath -Name 'AllowSearchToUseLocation' -Value 0 -Type DWord -Force | Out-Null # Disable Bing Search in Windows Search (HKCU Fallback) $searchPolicyPathCU = 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' if (!(Test-Path $searchPolicyPathCU)) { New-Item -Path $searchPolicyPathCU -Force | Out-Null } Set-ItemProperty -Path $searchPolicyPathCU -Name 'DisableWebSearch' -Value 1 -Type DWord -Force | Out-Null Set-ItemProperty -Path $searchPolicyPathCU -Name 'ConnectedSearchUseWeb' -Value 0 -Type DWord -Force | Out-Null # Disable Bing Search in Edge (address bar) $edgePolicyPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Edge' if (!(Test-Path $edgePolicyPath)) { New-Item -Path $edgePolicyPath -Force | Out-Null } Set-ItemProperty -Path $edgePolicyPath -Name 'DefaultSearchProviderEnabled' -Value 0 -Type DWord -Force | Out-Null Set-ItemProperty -Path $edgePolicyPath -Name 'HideFirstRunExperience' -Value 1 -Type DWord -Force | Out-Null # Remove Bing Search as default (set Google or generic) $edgeSearchPolicyPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Edge\SearchEngines' if (!(Test-Path $edgeSearchPolicyPath)) { New-Item -Path $edgeSearchPolicyPath -Force | Out-Null } Set-ItemProperty -Path $edgeSearchPolicyPath -Name 'AllowSearchEngineCustomization' -Value 1 -Type DWord -Force | Out-Null # Disable Copilot in Windows (Bing AI integration) $copilotPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsCopilot' if (!(Test-Path $copilotPath)) { New-Item -Path $copilotPath -Force | Out-Null } Set-ItemProperty -Path $copilotPath -Name 'TurnOffWindowsCopilot' -Value 1 -Type DWord -Force | Out-Null # Disable Copilot in Edge $edgeCopilotPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Edge' if (!(Test-Path $edgeCopilotPath)) { New-Item -Path $edgeCopilotPath -Force | Out-Null } Set-ItemProperty -Path $edgeCopilotPath -Name 'CopilotEnabled' -Value 0 -Type DWord -Force | Out-Null Set-ItemProperty -Path $edgeCopilotPath -Name 'CopilotCDPPageContext' -Value 0 -Type DWord -Force | Out-Null # Disable Bing sidebar in Edge Set-ItemProperty -Path $edgePolicyPath -Name 'HubsSidebarEnabled' -Value 0 -Type DWord -Force | Out-Null Set-ItemProperty -Path $edgePolicyPath -Name 'DiscoverPageContextEnabled' -Value 0 -Type DWord -Force | Out-Null Set-ItemProperty -Path $edgePolicyPath -Name 'WebWidgetAllowed' -Value 0 -Type DWord -Force | Out-Null # Remove Bing from Windows Search via registry (block bing.com in search) if((Test-Path -LiteralPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search") -ne $true) { New-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -force -ea SilentlyContinue }; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search' -Name 'BingSearchEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search' -Name 'AllowSearchToUseLocation' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; New-ItemProperty -LiteralPath 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search' -Name 'CortanaConsent' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue; # Disable Microsoft Search in Bing (for enterprise) $msSearchPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Search' if (!(Test-Path $msSearchPath)) { New-Item -Path $msSearchPath -Force | Out-Null } Set-ItemProperty -Path $msSearchPath -Name 'DisableSearch' -Value 1 -Type DWord -Force | Out-Null # ============================================================================== # FIM: TWEAKS-USER.ps1 # ============================================================================== # Verificar e instalar Scoop Write-Host "A verificar Scoop..." -ForegroundColor Yellow if (Get-Command scoop -ErrorAction SilentlyContinue) { Write-Host " OK Scoop ja esta instalado. A continuar..." -ForegroundColor Green } else { Write-Host " -> A instalar Scoop..." -ForegroundColor Cyan # Instalar Scoop de forma mais segura try { $installScript = Invoke-RestMethod -Uri "https://get.scoop.sh" -ErrorAction Stop $installScript | Out-File -FilePath "$env:TEMP\scoop-install.ps1" -Force & "$env:TEMP\scoop-install.ps1" -RunAsAdmin $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") if (Get-Command scoop -ErrorAction SilentlyContinue) { Write-Host " OK Scoop instalado com sucesso." -ForegroundColor Green } else { Write-Host " ! Scoop foi instalado, mas pode necessitar de abrir um novo terminal." -ForegroundColor Yellow } } catch { Write-Host " X Erro ao instalar Scoop: $_" -ForegroundColor Red } } Write-Host "" # Check winget if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { Write-Host "ERRO: winget nao esta disponivel. Instale o 'App Installer' pela Microsoft Store." -ForegroundColor Red Stop-Transcript | Out-Null exit 1 } # Update winget sources Write-Host "A atualizar fontes do winget..." -ForegroundColor Cyan winget source update | Out-Null Write-Host "" # Funcao robusta para verificar se a app ja esta instalada via winget function Test-AppInstalled { param($AppId) try { $output = & winget list --id $AppId 2>$null return ($output -match [regex]::Escape($AppId)) } catch { return $false } } # Funcao para verificar se uma aplicacao esta registada no Windows (instaladores fora do winget) function Test-AppRegistered { param([string]$NamePattern) $uninstallKeys = @( "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" ) foreach ($key in $uninstallKeys) { $found = Get-ItemProperty -Path $key -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like $NamePattern } if ($found) { return $true } } return $false } # Funcao para instalar aplicacao com verificacao previa function Install-App { param($AppId, $AppName) Write-Host "A verificar $AppName..." -ForegroundColor Yellow if (Test-AppInstalled -AppId $AppId) { Write-Host " OK $AppName ja esta instalado. A continuar..." -ForegroundColor Green return $true } Write-Host " -> A instalar $AppName..." -ForegroundColor Cyan winget install --id $AppId --silent --accept-source-agreements --accept-package-agreements --force | Out-Null if (Test-AppInstalled -AppId $AppId) { Write-Host " OK $AppName instalado com sucesso." -ForegroundColor Green return $true } else { Write-Host " X Falha na instalacao de $AppName (codigo: $LASTEXITCODE)" -ForegroundColor Red return $false } } Write-Host "A verificar e instalar aplicacoes..." -ForegroundColor Cyan Write-Host "" # Lista de aplicacoes (Git adicionado ANTES do UniGetUI) winget.exe uninstall --id "7zip.7zip" --exact --source winget --accept-source-agreements --disable-interactivity --version "26.06" --silent $apps = @( @{Id= "Python.Python.3.14"; Name= "Python 3.14"}, @{Id= "Git.Git"; Name= "Git"}, @{Id= "OpenJS.NodeJS"; Name= "Node.JS"}, @{Id= "Mozilla.Firefox"; Name= "Firefox (PT-PT)"}, @{Id= "Stremio.Stremio"; Name= "Stremio"}, # NOTA: O OpenCode Desktop (v2) e instalado numa seccao propria mais abaixo. # O ID winget "SST.OpenCodeDesktop" esta preso na linha v1 (1.19.x). @{Id= "cURL.cURL"; Name= "cURL"}, @{Id= "Oven-sh.Bun"; Name= "Bun"}, @{Id= "ggml.llamacpp"; Name= "llama.cpp"}, @{Id= "CodeSector.TeraCopy"; Name= "TeraCopy 4.0.3"}, @{Id= "Devolutions.UniGetUI"; Name= "UniGetUI"}, @{Id= "Google.ChromeRemoteDesktopHost"; Name= "Google.ChromeRemoteDesktopHost"}, @{Id= "LocalSend.LocalSend"; Name= "LocalSend"}, @{Id= "tailscale.tailscale"; Name= "tailscale"}, @{Id= "Giorgiotani.Peazip"; Name= "Peazip"} # NOTA: O Llama (llama.app / Llama-Windows) e instalado numa seccao propria # mais abaixo, a partir do ultimo release do GitHub. O ID MSIX fixo usado # antes (@{Id= "MSIX\HuggingFaceInc.LlamaApp_0.14.1.0_..."}) mudava a cada # versao e falhava em maquinas novas. ) $successCount = 0 $failCount = 0 foreach ($app in $apps) { $result = Install-App -AppId $app.Id -AppName $app.Name if ($result) { $successCount++ } else { $failCount++ } Write-Host "" } Start-Sleep -Seconds 5 taskkill /IM "tailscale-ipn.exe" /F # ========================================== # INSTALAR OPENCODE DESKTOP v2 (ultima versao) # https://opencode.ai/desktop # ========================================== Write-Host "" Write-Host "=== A instalar OpenCode Desktop (v2) ===" -ForegroundColor Magenta # O ID winget "SST.OpenCodeDesktop" esta preso na linha v1 (1.19.x), por isso # usamos a API oficial de atualizacoes, que devolve sempre a versao v2 atual # e o instalador correspondente (o mesmo link de https://opencode.ai/desktop). function Get-OpenCodeDesktopInstall { $uninstallKeys = @( "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" ) $entries = Get-ItemProperty -Path $uninstallKeys -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -eq 'd074f30d-5f88-5885-b075-be1348cc7676' -or $_.DisplayName -like 'OpenCode*' } $best = $null foreach ($entry in $entries) { $version = $null if ($entry.DisplayVersion) { try { $version = [version]$entry.DisplayVersion } catch { } } if (-not $version -and $entry.DisplayName -match '(\d+(\.\d+){1,3})$') { try { $version = [version]$Matches[1] } catch { } } if (-not $best -or ($version -and (-not $best.Version -or $version -gt $best.Version))) { $best = [pscustomobject]@{ Version = $version DisplayVersion = $entry.DisplayVersion DisplayName = $entry.DisplayName InstallLocation = $entry.InstallLocation } } } return $best } $ocInstalled = Get-OpenCodeDesktopInstall $ocInstallNeeded = $true $ocSetup = $null try { Write-Host " -> A obter a ultima versao do OpenCode Desktop..." -ForegroundColor Cyan [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $ocRelease = Invoke-RestMethod -Uri "https://opencode.ai/update/api/latest/desktop/opencode/" -Headers @{ "User-Agent" = "opencode-installer" } -ErrorAction Stop $ocLatest = [version]$ocRelease.version if ($ocInstalled -and $ocInstalled.Version -and $ocInstalled.Version -ge $ocLatest) { Write-Host (" OK OpenCode Desktop ja esta instalado e atualizado (versao {0})." -f $ocInstalled.Version) -ForegroundColor Green $ocInstallNeeded = $false $successCount++ } elseif ($ocInstalled) { $ocInstalledLabel = if ($ocInstalled.Version) { $ocInstalled.Version } else { 'desconhecida' } Write-Host (" -> A atualizar OpenCode Desktop de {0} para {1}..." -f $ocInstalledLabel, $ocLatest) -ForegroundColor Cyan } else { Write-Host (" -> OpenCode Desktop nao encontrado. A instalar a versao {0}..." -f $ocLatest) -ForegroundColor Cyan } if ($ocInstallNeeded) { switch ($env:PROCESSOR_ARCHITECTURE) { 'AMD64' { $ocAssetName = 'opencode-desktop-win-x64.exe' } 'ARM64' { $ocAssetName = 'opencode-desktop-win-arm64.exe' } default { throw "Arquitetura nao suportada: $env:PROCESSOR_ARCHITECTURE" } } $ocAsset = $ocRelease.metadata.files.$ocAssetName if (-not $ocAsset) { throw "Instalador '$ocAssetName' nao encontrado para a versao $ocLatest." } $ocSetup = Join-Path $env:TEMP $ocAssetName Write-Host (" -> A descarregar {0} (~{1} MB)..." -f $ocAssetName, [math]::Round($ocAsset.size / 1MB, 1)) -ForegroundColor Cyan try { Start-BitsTransfer -Source $ocAsset.url -Destination $ocSetup -Description "OpenCode Desktop" -ErrorAction Stop } catch { Write-Host " -> BITS indisponivel, a usar Invoke-WebRequest..." -ForegroundColor Yellow Invoke-WebRequest -Uri $ocAsset.url -OutFile $ocSetup -UseBasicParsing } if ($ocAsset.sha256) { $ocHash = (Get-FileHash -Path $ocSetup -Algorithm SHA256).Hash if ($ocHash -ne $ocAsset.sha256.ToUpper()) { throw "Hash SHA256 do instalador nao corresponde (esperado $($ocAsset.sha256))." } Write-Host " OK Integridade do instalador verificada (SHA256)." -ForegroundColor Green } # Fecha o OpenCode se estiver aberto, para o instalador poder substituir os ficheiros Get-Process -Name 'OpenCode' -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue Write-Host " -> A instalar em modo silencioso..." -ForegroundColor Cyan Start-Process -FilePath $ocSetup -ArgumentList "/S" -Wait $ocInstalled = Get-OpenCodeDesktopInstall if ($ocInstalled -and $ocInstalled.Version -and $ocInstalled.Version -ge $ocLatest) { Write-Host (" OK OpenCode Desktop instalado com sucesso (versao {0})." -f $ocInstalled.Version) -ForegroundColor Green $successCount++ } else { Write-Host " X OpenCode Desktop nao foi detetado na versao esperada apos a instalacao." -ForegroundColor Red $failCount++ } } } catch { Write-Host " X Erro ao instalar OpenCode Desktop: $_" -ForegroundColor Red $failCount++ } finally { if ($ocSetup) { Remove-Item $ocSetup -Force -ErrorAction SilentlyContinue } } # ========================================== # INSTALAR LLAMA (llama.app / Llama-Windows) # App: https://llama.app/ # GitHub: https://github.com/ggml-org/Llama-Windows # ========================================== Write-Host "" Write-Host "=== A instalar Llama (llama.app) ===" -ForegroundColor Magenta # O Llama para Windows e o mesmo projeto nos dois links: # - llama.app -> pagina oficial de download (envia para o GitHub) # - Llama-Windows -> repositorio que publica os pacotes .msixbundle # Por isso instalamos sempre o ultimo release do GitHub, em vez de usar um ID # MSIX fixo do winget (esse ID muda a cada versao e falha em maquinas novas). function Get-LlamaAppPackage { Get-AppxPackage -Name "HuggingFaceInc.LlamaApp" -ErrorAction SilentlyContinue } $llamaPackage = Get-LlamaAppPackage $llamaUpdateNeeded = -not $llamaPackage $llamaBundle = $null try { Write-Host " -> A verificar a ultima versao do Llama-Windows no GitHub..." -ForegroundColor Cyan [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $llamaRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/ggml-org/Llama-Windows/releases/latest" -Headers @{ "User-Agent" = "llama-installer" } -ErrorAction Stop $llamaLatest = $llamaRelease.tag_name -replace '^[vV]', '' if ($llamaPackage) { Write-Host (" OK Llama ja esta instalado (versao {0})." -f $llamaPackage.Version) -ForegroundColor Green if ($llamaLatest -match '^\d+(\.\d+){1,3}$') { $llamaInstalledBase = [version]("{0}.{1}.{2}" -f $llamaPackage.Version.Major, $llamaPackage.Version.Minor, $llamaPackage.Version.Build) $llamaUpdateNeeded = [version]$llamaLatest -gt $llamaInstalledBase if ($llamaUpdateNeeded) { Write-Host (" -> A atualizar de {0} para {1}..." -f $llamaPackage.Version, $llamaLatest) -ForegroundColor Cyan } else { Write-Host " OK Llama ja esta na versao mais recente." -ForegroundColor Green } } } else { Write-Host " -> Llama nao encontrado. A instalar a versao mais recente..." -ForegroundColor Cyan } if ($llamaUpdateNeeded) { $llamaAsset = $llamaRelease.assets | Where-Object { $_.name -like '*.msixbundle' } | Select-Object -First 1 if (-not $llamaAsset) { throw "Nenhum ficheiro .msixbundle encontrado no release $($llamaRelease.tag_name)." } $llamaBundle = Join-Path $env:TEMP $llamaAsset.name Write-Host (" -> A descarregar {0} (~{1} MB)..." -f $llamaAsset.name, [math]::Round($llamaAsset.size / 1MB, 1)) -ForegroundColor Cyan try { Start-BitsTransfer -Source $llamaAsset.browser_download_url -Destination $llamaBundle -Description "Llama (llama.app)" -ErrorAction Stop } catch { Write-Host " -> BITS indisponivel, a usar Invoke-WebRequest..." -ForegroundColor Yellow Invoke-WebRequest -Uri $llamaAsset.browser_download_url -OutFile $llamaBundle -UseBasicParsing } Write-Host " -> A instalar o pacote MSIX..." -ForegroundColor Cyan Add-AppxPackage -Path $llamaBundle -ForceApplicationShutdown -ErrorAction Stop $llamaPackage = Get-LlamaAppPackage if ($llamaPackage) { Write-Host (" OK Llama instalado com sucesso (versao {0})." -f $llamaPackage.Version) -ForegroundColor Green $successCount++ } else { Write-Host " X Llama nao foi detetado apos a instalacao." -ForegroundColor Red $failCount++ } } else { $successCount++ } } catch { Write-Host " X Erro ao instalar o Llama: $_" -ForegroundColor Red $failCount++ } finally { if ($llamaBundle) { Remove-Item $llamaBundle -Force -ErrorAction SilentlyContinue } } # CLI oficial do llama.app (llama.exe em %LOCALAPPDATA%\Microsoft\WindowsApps) $llamaCli = Join-Path $env:LOCALAPPDATA "Microsoft\WindowsApps\llama.exe" if (Test-Path $llamaCli) { Write-Host " OK CLI 'llama' ja esta instalada. A continuar..." -ForegroundColor Green $successCount++ } else { Write-Host " -> A instalar a CLI 'llama' (https://llama.app/install.ps1)..." -ForegroundColor Cyan $llamaInstallPath = Join-Path $env:TEMP "llama-app-install.ps1" try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 Invoke-WebRequest -Uri "https://llama.app/install.ps1" -OutFile $llamaInstallPath -UseBasicParsing -ErrorAction Stop Unblock-File -Path $llamaInstallPath -ErrorAction SilentlyContinue & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $llamaInstallPath $llamaCliExit = $LASTEXITCODE if (Test-Path $llamaCli) { Write-Host " OK CLI 'llama' instalada com sucesso." -ForegroundColor Green $successCount++ } elseif ($llamaCliExit -ne 0) { Write-Host " X Falha na instalacao da CLI 'llama' (codigo: $llamaCliExit)." -ForegroundColor Red $failCount++ } else { Write-Host " X CLI 'llama' nao foi detetada apos a instalacao." -ForegroundColor Red $failCount++ } } catch { Write-Host " X Erro ao instalar a CLI 'llama': $_" -ForegroundColor Red $failCount++ } finally { Remove-Item $llamaInstallPath -Force -ErrorAction SilentlyContinue } } # ========================================== # INSTALAR FREELIMAPI (FreeLLMAPI Desktop) # https://github.com/tashfeenahmed/freellmapi # ========================================== Write-Host "" Write-Host "=== Instalando FreeLLMAPI (FreeLLM API) ===" -ForegroundColor Magenta choco.exe install freellmapi -y --no-progress # ========================================== # INSTALAR FERRAMENTAS CLI VIA SCOOP (llmfit) # ========================================== Write-Host "" Write-Host "=== Instalando ferramentas CLI via Scoop ===" -ForegroundColor Magenta $scoopApps = @("llmfit") foreach ($cliApp in $scoopApps) { if (Get-Command $cliApp -ErrorAction SilentlyContinue) { Write-Host " OK $cliApp ja esta instalado. A continuar..." -ForegroundColor Green $successCount++ continue } try { Write-Host " -> A instalar $cliApp via Scoop..." -ForegroundColor Cyan scoop install $cliApp if ($LASTEXITCODE -eq 0 -or (Get-Command $cliApp -ErrorAction SilentlyContinue)) { Write-Host " OK $cliApp instalado com sucesso via Scoop." -ForegroundColor Green $successCount++ } else { Write-Host " X Falha na instalacao de $cliApp via Scoop." -ForegroundColor Red $failCount++ } } catch { Write-Host " X Erro ao instalar $cliApp via Scoop: $_" -ForegroundColor Red $failCount++ } } # ========================================== # INSTALAR FERRAMENTAS CLI VIA NPM (opencode CLI - apenas o CLI, nao o Desktop) # ========================================== Write-Host "" Write-Host "=== Instalando opencode via NPM ===" -ForegroundColor Magenta npm install -g @opencode/cli@latest --silent # ========================================== # INSTALAR DEEPSEEK HARNESS (Desktop) # https://www.deepseek.com/en/harness/ # ========================================== Write-Host "" Write-Host "=== A instalar DeepSeek Harness (Desktop) ===" -ForegroundColor Magenta # Funcao para localizar o executavel do DeepSeek Harness function Get-DeepSeekHarnessExe { # 1. Instalacao por-utilizador (instalador NSIS do electron-builder) $candidato = Join-Path $env:LOCALAPPDATA "Programs\DeepSeek Harness\DeepSeek Harness.exe" if (Test-Path $candidato) { return $candidato } # 2. Instalacao por-maquina $candidato = Join-Path $env:ProgramFiles "DeepSeek Harness\DeepSeek Harness.exe" if (Test-Path $candidato) { return $candidato } # 3. Registo de desinstalacao (fallback) $uninstallKeys = @( "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" ) foreach ($key in $uninstallKeys) { $entrada = Get-ItemProperty -Path $key -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -like "*DeepSeek Harness*" } | Select-Object -First 1 if ($entrada) { if ($entrada.InstallLocation) { $exe = Join-Path $entrada.InstallLocation "DeepSeek Harness.exe" if (Test-Path $exe) { return $exe } } if ($entrada.DisplayIcon) { $icone = ($entrada.DisplayIcon -split ",")[0].Trim('"') if (Test-Path $icone) { return $icone } } } } return $null } $dshExe = Get-DeepSeekHarnessExe if ($dshExe) { Write-Host " OK DeepSeek Harness ja esta instalado. A continuar..." -ForegroundColor Green $successCount++ } else { Write-Host " -> A descarregar o instalador oficial do DeepSeek Harness (~276 MB)..." -ForegroundColor Cyan $dshUrl = "https://download.deepseek.com/desktop/dsh-latest-windows-x64.exe" $dshSetup = Join-Path $env:TEMP "DeepSeek-Harness-Setup.exe" try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 try { # BITS mostra progresso e permite retomar o download Start-BitsTransfer -Source $dshUrl -Destination $dshSetup -Description "DeepSeek Harness" -ErrorAction Stop } catch { Write-Host " -> BITS indisponivel, a usar Invoke-WebRequest..." -ForegroundColor Yellow Invoke-WebRequest -Uri $dshUrl -OutFile $dshSetup -UseBasicParsing } $tamanhoMb = [math]::Round((Get-Item $dshSetup).Length / 1MB, 1) Write-Host " -> Instalador descarregado ($tamanhoMb MB). A instalar em modo silencioso..." -ForegroundColor Cyan Start-Process -FilePath $dshSetup -ArgumentList "/S" -Wait $dshExe = Get-DeepSeekHarnessExe if ($dshExe) { Write-Host " OK DeepSeek Harness instalado com sucesso." -ForegroundColor Green $successCount++ } else { Write-Host " X DeepSeek Harness nao foi detetado apos a instalacao." -ForegroundColor Red $failCount++ } } catch { Write-Host " X Erro ao instalar DeepSeek Harness: $_" -ForegroundColor Red $failCount++ } finally { Remove-Item $dshSetup -Force -ErrorAction SilentlyContinue } } # Atalho no Ambiente de Trabalho com o icone da aplicacao if ($dshExe) { try { $atalhoDsh = Join-Path ([Environment]::GetFolderPath('Desktop')) "DeepSeek Harness.lnk" $wshShell = New-Object -ComObject WScript.Shell $atalho = $wshShell.CreateShortcut($atalhoDsh) $atalho.TargetPath = $dshExe $atalho.WorkingDirectory = Split-Path $dshExe -Parent $atalho.Description = "DeepSeek Harness - Agent Desktop" $atalho.IconLocation = "$dshExe,0" $atalho.Save() Write-Host " OK Atalho 'DeepSeek Harness' criado no Ambiente de Trabalho." -ForegroundColor Green } catch { Write-Host " X Erro ao criar o atalho do DeepSeek Harness: $_" -ForegroundColor Red } } # ========================================== # DESATIVAR ARRANQUE AUTOMATICO # ========================================== Write-Host "" Write-Host "A desativar arranque automatico de aplicacoes..." -ForegroundColor Cyan function Disable-StartupItem { param([string]$AppName) Write-Host " -> A processar: $AppName" -ForegroundColor Yellow $found = $false # 1. Registo (HKCU/HKLM Run + RunOnce, 32 e 64 bits) $regPaths = @( "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run", "HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run", "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\RunOnce" ) foreach ($path in $regPaths) { if (Test-Path $path) { $props = Get-ItemProperty -Path $path -ErrorAction SilentlyContinue if ($null -ne $props) { $matches = $props.PSObject.Properties | Where-Object { ($_.Name -ne "PSPath") -and ($_.Name -ne "PSParentPath") -and ($_.Name -ne "PSChildName") -and ($_.Name -ne "PSDrive") -and ($_.Name -ne "PSProvider") -and (($_.Name -match $AppName) -or ("$($_.Value)" -match $AppName)) } foreach ($m in $matches) { try { Remove-ItemProperty -Path $path -Name $m.Name -Force -ErrorAction SilentlyContinue Write-Host " X Removido do Registo: [$path] $($m.Name)" -ForegroundColor DarkYellow $found = $true } catch {} } } } } # 2. Pastas de Startup (utilizador atual e todos os utilizadores) $startupFolders = @( [Environment]::GetFolderPath('Startup'), [Environment]::GetFolderPath('CommonStartup') ) foreach ($folder in $startupFolders) { if (Test-Path $folder) { Get-ChildItem -Path $folder -Filter "*$AppName*" -ErrorAction SilentlyContinue | ForEach-Object { try { Remove-Item $_.FullName -Force -ErrorAction SilentlyContinue Write-Host " X Removido da pasta Startup: $($_.Name)" -ForegroundColor DarkYellow $found = $true } catch {} } } } if ($found) { Write-Host " OK Arranque automatico desativado para $AppName" -ForegroundColor Green } else { Write-Host " i Nenhuma entrada encontrada para $AppName (pode ja estar desativado)" -ForegroundColor DarkGray } } Disable-StartupItem -AppName "OneDrive" Disable-StartupItem -AppName "UniGetUI" # Garante que o script corre com privilégios de Administrador if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs Exit } Write-Host "A desativar a partilha protegida por palavra-passe..." -ForegroundColor Cyan # 1. Altera a chave de registo para permitir acesso anónimo a partilhas (Desativar Proteção por Senha) Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name "everyoneincludesanonymous" -Value 1 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "restrictanonymous" -Value 0 # 2. Reinicia o serviço de partilhas (Servidor) para aplicar as alterações imediatamente Write-Host "A reiniciar o serviço de rede..." -ForegroundColor Yellow Restart-Service -Name "LanmanServer" -Force Write-Host "Concluído com sucesso! A partilha sem senha está ativa." -ForegroundColor Green Start-Sleep -Seconds 5 # ============================================================================== # SCRIPT DE OTIMIZAÇÃO WINDOWS 11 (2026) - 24GB RAM + SSD # ============================================================================== Write-Host "A aplicar tweaks de desempenho e memória..." -ForegroundColor Cyan # 1. Interface e Menus # Restaura o menu de contexto clássico (botão direito do rato antigo) New-Item -Path "HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" -Force | Out-Null # Remove o atraso visual na abertura de menus do sistema Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Value 0 -Force # Desativa sugestões de pesquisa web e do Copilot no Menu Iniciar Set-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Explorer" -Name "DisableSearchBoxSuggestions" -Value 1 -Force # 2. Gestão de Memória RAM (Calibrado para 24 GB) # Agrupa processos de serviços em segundo plano para poupar memória RAM Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control" -Name "SvcHostSplitThresholdInKB" -Value 25165824 -Force # Força a prioridade na memória RAM física em vez do ficheiro de paginação Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "SystemPages" -Value 4294967295 -Force # 3. Otimizações de Armazenamento (Exclusivo para SSD) # Desativa a cache de ficheiros do sistema para libertar RAM para os jogos Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "LargeSystemCache" -Value 0 -Force # Mantém controladores (drivers) e o kernel diretamente na RAM (reduz latência) Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "DisablePagingExecutive" -Value 1 -Force # Aumenta a velocidade de transferência e elimina micro-travamentos (stuttering) no SSD Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "IoPageLockLimit" -Value 16777216 -Force # Otimiza o desempenho de leitura/escrita do sistema de ficheiros NTFS Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "NtfsMemoryUsage" -Value 2 -Force # 4. Serviços em Segundo Plano e Telemetria # Desativa o SysMain/Superfetch (inútil em SSDs e poupa RAM no arranque) Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters" -Name "EnableSuperfetch" -Value 0 -Force # Desativa os serviços de recolha de dados e telemetria da Microsoft em segundo plano Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Value 0 -Force Write-Host "Otimizações aplicadas com sucesso! Reinicie o PC para efetivar as alterações." -ForegroundColor Green # ============================================================================== # SCRIPT DE OTIMIZAÇÃO DE GPU & LATÊNCIA - LEGION 5 (RTX 3060 + RYZEN 7) # ============================================================================== Write-Host "A otimizar a RTX 3060 e a latência do Ryzen 7..." -ForegroundColor Cyan # 1. Ativar Hardware-Accelerated GPU Scheduling (HAGS) # Essencial para reduzir o uso do CPU e melhorar a estabilidade dos FPS na RTX 3060 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name "HwSchMode" -Value 2 -Force # 2. Forçar Modo de Energia de Alto Desempenho na Placa Gráfica (NVIDIA) Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name "PowerMizerEnable" -Value 1 -Force Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name "MainDisplayPriority" -Value 1 -Force # 3. Mitigar Latência de Áudio/Vídeo e dPC (Otimização para o Ryzen 7) # Melhora a prioridade de resposta a tarefas em tempo real (jogos) Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "NetworkThrottlingIndex" -Value 4294967295 -Force Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "SystemResponsiveness" -Value 0 -Force # Priorizar Jogos no Agendador de Tarefas do Sistema Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games" -Name "GPU Priority" -Value 8 -Force Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games" -Name "Priority" -Value 6 -Force Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games" -Name "Scheduling Category" -Value "High" -Force Write-Host "Otimizações de GPU aplicadas! Reinicia o portátil para ativar." -ForegroundColor Green # ========================================== # Add user # ========================================== net user rede 1234 /add net localgroup administrators rede /add Start-Sleep -Seconds 5 Write-Host "User ADD " -ForegroundColor Green Start-Sleep -Seconds 5 Copy-Item "C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\LocalSend.lnk" -Destination "C:\Users\Administrator\Desktop" Remove-Item -Path "c:\ip.bat" -Recurse -Force -ErrorAction SilentlyContinue Remove-Item -Path "c:\*.txt.bat" -Recurse -Force -ErrorAction SilentlyContinue # 1. Define o caminho do ficheiro único .bat no Ambiente de Trabalho $CaminhoBat = Join-Path ([Environment]::GetFolderPath('Desktop')) "Atualizar-Atalhos-Tailscale.bat" # 2. Conteúdo do .bat que cria, executa e limpa o script de forma invisível $ConteudoBat = @' @echo off title Atualizar Atalhos Tailscale echo A ler dinamicamente todas as maquinas do Tailscale... :: Cria um ficheiro temporário escondido para o processamento set "TEMP_PS1=%TEMP%\ts_shortcuts_temp.ps1" :: Escreve o bloco completo de PowerShell diretamente (evita erros com parênteses e variáveis) ( echo $LinhasTailscale = tailscale status echo $AmbienteTrabalho = [Environment]::GetFolderPath('Desktop'^) echo $WScriptShell = New-Object -ComObject WScript.Shell echo $MaquinasAtuais = @(^) echo $Contador = 0 echo foreach ($Linha in $LinhasTailscale^) { echo if ([string]::IsNullOrWhiteSpace($Linha^)^) { continue } echo $Colunas = $Linha -split '\s+' echo if ($Colunas.Count -ge 4 -and $Linha -like "*windows*"^) { echo $IPRemoto = $Colunas[0] echo $NomeCompleto = $Colunas[1] echo $NomeLimpo = $NomeCompleto.Split('.'^)[0] echo $MaquinasAtuais += $NomeLimpo echo $ShortcutFile = Join-Path $AmbienteTrabalho "$NomeLimpo.lnk" echo $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile^) echo $Shortcut.TargetPath = "C:\Windows\explorer.exe" echo $Shortcut.Arguments = "\\$IPRemoto" echo $Shortcut.Description = "Acesso Tailscale para $NomeLimpo ($IPRemoto)" echo $Shortcut.IconLocation = "C:\Windows\System32\shell32.dll,88" echo $Shortcut.Save(^) echo Write-Host "Atalho criado/atualizado: $NomeLimpo ($IPRemoto)" -ForegroundColor Green echo $Contador++ echo } echo } echo Write-Host "`nA verificar se existem atalhos antigos para remover..." -ForegroundColor Yellow echo $TodosOsAtalhos = Get-ChildItem -Path $AmbienteTrabalho -Filter "*.lnk" echo foreach ($Atalho in $TodosOsAtalhos^) { echo $NomeAtalho = $Atalho.BaseName echo $ShortcutObj = $WScriptShell.CreateShortcut($Atalho.FullName^) echo if ($ShortcutObj.TargetPath -like "*explorer.exe*" -and $ShortcutObj.Arguments -like "\\100.*"^) { echo if ($MaquinasAtuais -notcontains $NomeAtalho^) { echo Remove-Item $Atalho.FullName -Force echo Write-Host "Atalho antigo removido: $NomeAtalho" -ForegroundColor Red echo } echo } echo } echo Write-Host "`nProcesso concluido. Total de atalhos ativos: $Contador" -ForegroundColor Cyan ) > "%TEMP_PS1%" Start-Process "$HOME\Desktop\Atualizar-Atalhos-Tailscale.bat" -Wait :: Executa o ficheiro temporário usando o PowerShell 5.1 nativo powershell -NoProfile -ExecutionPolicy Bypass -File "%TEMP_PS1%" :: Apaga o ficheiro temporário para manter o sistema limpo if exist "%TEMP_PS1%" del "%TEMP_PS1%" echo. echo Concluido! Pressione qualquer tecla para fechar esta janela. pause > nul '@ # 3. Elimina o ficheiro de script antigo do Desktop se existir para não deixar lixo $ScriptAntigo = Join-Path ([Environment]::GetFolderPath('Desktop')) "Atualizar-Atalhos-Script.ps1" if (Test-Path $ScriptAntigo) { Remove-Item $ScriptAntigo -Force } # 4. Escreve o ficheiro .bat único final [System.IO.File]::WriteAllText($CaminhoBat, $ConteudoBat) Write-Host "[Sucesso] Ficheiro único 'Atualizar-Atalhos-Tailscale.bat' gerado no Ambiente de Trabalho com o ícone correto!" -ForegroundColor Green Remove-Item "C:\Users\Administrator\Desktop\PeaZip.lnk" -Force # ========================================== # Mudar Nome PC # ========================================== # Rename PC $newName = Read-Host " Enter new computer name" Try { Rename-Computer -NewName $newName -Force -ErrorAction Stop Write-Host " -> Rename command sent." -ForegroundColor Green } Catch { Write-Warning " Rename failed: $($_.Exception.Message)" } # Summary Write-Host "" Write-Host "=== Resumo ===" -ForegroundColor Cyan Write-Host "Instalacoes com sucesso: $successCount" -ForegroundColor Green if ($failCount -gt 0) { Write-Host "Falhas: $failCount" -ForegroundColor Red } Write-Host "" Write-Host "Registo guardado em: $logFile" -ForegroundColor Cyan Stop-Transcript | Out-Null # Perguntar se deseja reiniciar Write-Host "" Write-Host "Pretende reiniciar o computador agora? [S/N]" -ForegroundColor Yellow $response = Read-Host if ($response -eq "S" -or $response -eq "s") { Write-Host "O sistema ira reiniciar em 30 segundos..." -ForegroundColor Yellow Start-Sleep -Seconds 30 Restart-Computer -Force } else { Write-Host "Reinicio cancelado pelo utilizador." -ForegroundColor Green Write-Host "Recomenda-se reiniciar manualmente para aplicar todas as alteracoes." -ForegroundColor Yellow }