{"id":809287,"date":"2026-05-18T06:55:37","date_gmt":"2026-05-18T06:55:37","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=809287"},"modified":"2026-05-18T06:55:37","modified_gmt":"2026-05-18T06:55:37","slug":"desabilitar-ou-habilitar-o-windows-run-dialog-powershell","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/pt-br\/script-hub\/desabilitar-ou-habilitar-o-windows-run-dialog-powershell\/","title":{"rendered":"Como desativar ou ativar a caixa de di\u00e1logo Executar do Windows com o PowerShell"},"content":{"rendered":"<p>No intrincado mundo da TI, o gerenciamento do acesso do usu\u00e1rio a determinados recursos do sistema \u00e9 de extrema import\u00e2ncia. Um desses recursos \u00e9 a caixa de di\u00e1logo Executar do Windows. Mas por que os profissionais de TI querem restringir seu acesso? Este guia se aprofunda no <strong>script do PowerShell criado para controlar a acessibilidade da caixa de di\u00e1logo Executar<\/strong> e as implica\u00e7\u00f5es de tais a\u00e7\u00f5es.<\/p>\n<h2>Vis\u00e3o geral da caixa de di\u00e1logo Executar do Windows<\/h2>\n<ul>\n<li>\n<h3>O que \u00e9 a caixa de di\u00e1logo Executar do Windows?<\/h3>\n<ul>\n<li>A caixa de di\u00e1logo Executar do Windows \u00e9 um recurso que oferece aos usu\u00e1rios uma maneira r\u00e1pida de iniciar programas, abrir pastas e executar comandos do sistema. Ao pressionar Windows + R, uma pequena caixa de di\u00e1logo \u00e9 exibida, permitindo que os usu\u00e1rios digitem os comandos diretamente.<\/li>\n<\/ul>\n<\/li>\n<li>\n<h3>Como \u00e9 usada a caixa de di\u00e1logo Executar do Windows?<\/h3>\n<ul>\n<li>Ele \u00e9 usado principalmente para acesso r\u00e1pido. Em vez de navegar por v\u00e1rios menus ou pastas, os usu\u00e1rios podem simplesmente digitar um comando ou caminho na caixa de di\u00e1logo Executar para iniciar instantaneamente um programa ou abrir um diret\u00f3rio.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"in-context-cta\"><p style=\"text-align: left;\">A caixa de di\u00e1logo Run \u00e9 um dos principais locais que as pessoas acessam quando desejam obter acesso ou executar comandos no sistema mais amplo. Como um ponto principal para a execu\u00e7\u00e3o de comandos e programas, o bloqueio apresenta um ambiente mais controlado e reduz significativamente o risco.<\/p>\n<p style=\"text-align: left;\">Embora esse n\u00e3o seja o \u00fanico ponto de execu\u00e7\u00e3o de comandos e programas, \u00e9 o mais usado por pessoas que n\u00e3o t\u00eam necessariamente experi\u00eancia em administra\u00e7\u00e3o de sistemas. O bloqueio deve ser usado em conjunto com outras restri\u00e7\u00f5es de seguran\u00e7a (como impedir o acesso ao registro ou ao prompt de comando).<\/p>\n<\/div>\n<h2>Implica\u00e7\u00f5es de seguran\u00e7a da desativa\u00e7\u00e3o da caixa de di\u00e1logo Executar do Windows<\/h2>\n<h3>Quais s\u00e3o os riscos?<\/h3>\n<p>Ao desativar a caixa de di\u00e1logo Executar, voc\u00ea pode, inadvertidamente, prejudicar a produtividade. Alguns usu\u00e1rios avan\u00e7ados confiam no Run Dialog para tarefas r\u00e1pidas e gerenciamento do sistema. Al\u00e9m disso, se n\u00e3o for feita corretamente, a adultera\u00e7\u00e3o das configura\u00e7\u00f5es do sistema pode levar a outros problemas n\u00e3o intencionais.<\/p>\n<h3>Quais s\u00e3o os benef\u00edcios?<\/h3>\n<p>O principal benef\u00edcio \u00e9 o aumento da seguran\u00e7a. Desativar a caixa de di\u00e1logo Executar pode evitar a\u00e7\u00f5es n\u00e3o autorizadas ou mal-intencionadas, especialmente de usu\u00e1rios que podem n\u00e3o ser bem versados em opera\u00e7\u00f5es do sistema. Isso reduz o risco de altera\u00e7\u00f5es acidentais ou a execu\u00e7\u00e3o de comandos prejudiciais.<\/p>\n<h3>Como voc\u00ea pode reduzir os riscos?<\/h3>\n<p>Antes de implementar qualquer mudan\u00e7a, \u00e9 essencial:<\/p>\n<ul>\n<li>Comunique-se com os usu\u00e1rios, especialmente aqueles que podem ser afetados pela mudan\u00e7a.<\/li>\n<li>Fornecer m\u00e9todos ou ferramentas alternativas para tarefas que antes eram realizadas usando a caixa de di\u00e1logo Executar.<\/li>\n<li>Certifique-se de que haja uma maneira de reverter rapidamente as altera\u00e7\u00f5es, se necess\u00e1rio.<\/li>\n<\/ul>\n<h2>Hist\u00f3rico<\/h2>\n<p>O script do PowerShell fornecido \u00e9 uma ferramenta robusta para que os profissionais de TI e os <a href=\"https:\/\/www.ninjaone.com\/what-is-an-msp\/\">provedores de servi\u00e7os gerenciados (MSPs)<\/a> controlem a acessibilidade da caixa de di\u00e1logo Executar. Em ambientes em que a seguran\u00e7a \u00e9 uma prioridade m\u00e1xima, essas ferramentas se tornam indispens\u00e1veis. A capacidade do script de excluir usu\u00e1rios espec\u00edficos dessas restri\u00e7\u00f5es acrescenta uma camada de flexibilidade, garantindo que o acesso necess\u00e1rio n\u00e3o seja completamente revogado.<\/p>\n<h2>O roteiro<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 2.0\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Disables or enables the Run Dialog for all users and new users.\r\n.DESCRIPTION\r\n    Disables or enables the Run Dialog for all users and new users, and there is an option to exclude users.\r\n    Reboot is required to apply changes.\r\n.EXAMPLE\r\n    -Disable\r\n    Disables the Run Dialog for all users and new users.\r\n.EXAMPLE\r\n    -Disable -ExcludeUsers \"Test1\", \"Test2\"\r\n    Disables the Run Dialog for all users and new users, but excludes Test1 and Test2 users.\r\n.EXAMPLE\r\n    -Enable\r\n    Enables the Run Dialog for all users and new users.\r\n.EXAMPLE\r\n    -Enable -ExcludeUsers \"Test1\", \"Test2\"\r\n    Enables the Run Dialog for all users and new users, but excludes Test1 and Test2 users.\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    General notes\r\n    Release Notes:\r\n    Initial Release\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter(Mandatory = $true, ParameterSetName = \"Disable\")]\r\n    [Switch]\r\n    $Disable,\r\n    [Parameter(Mandatory = $true, ParameterSetName = \"Enable\")]\r\n    [Switch]\r\n    $Enable,\r\n    [Parameter(Mandatory = $false, ParameterSetName = \"Disable\")]\r\n    [Parameter(Mandatory = $false, ParameterSetName = \"Enable\")]\r\n    [String[]]\r\n    $ExcludeUsers\r\n)\r\n\r\nbegin {\r\n    function Set-ItemProp {\r\n        param (\r\n            $Path,\r\n            $Name,\r\n            $Value,\r\n            [ValidateSet(\"DWord\", \"QWord\", \"String\", \"ExpandedString\", \"Binary\", \"MultiString\", \"Unknown\")]\r\n            $PropertyType = \"DWord\"\r\n        )\r\n        # Do not output errors and continue\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::SilentlyContinue\r\n        if (-not $(Test-Path -Path $Path)) {\r\n            # Check if path does not exist and create the path\r\n            New-Item -Path $Path -Force | Out-Null\r\n        }\r\n        if ((Get-ItemProperty -Path $Path -Name $Name)) {\r\n            # Update property and print out what it was changed from and changed to\r\n            $CurrentValue = Get-ItemProperty -Path $Path -Name $Name\r\n            try {\r\n                Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Error $_\r\n            }\r\n            Write-Host \"$Path$Name changed from $CurrentValue to $(Get-ItemProperty -Path $Path -Name $Name)\"\r\n        }\r\n        else {\r\n            # Create property with value\r\n            try {\r\n                New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false -ErrorAction Stop | Out-Null\r\n            }\r\n            catch {\r\n                Write-Error $_\r\n            }\r\n            Write-Host \"Set $Path$Name to $(Get-ItemProperty -Path $Path -Name $Name)\"\r\n        }\r\n        $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue\r\n    }\r\n}\r\nprocess {\r\n    $Path = \"SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer\"\r\n    $Name = \"NoRun\"\r\n    $Value = if ($Disable) { 1 }elseif ($Enable) { 0 }else {\r\n        Write-Host \"Either -Enable or -Disable is required to function.\"\r\n        exit 0\r\n    }\r\n\r\n    # Get each user profile SID and Path to the profile\r\n    $UserProfiles = Get-ItemProperty \"HKLM:SOFTWAREMicrosoftWindows NTCurrentVersionProfileList*\" |\r\n        Where-Object { $_.PSChildName -match \"S-1-5-21-(d+-?){4}$\" } |\r\n        Select-Object @{Name = \"SID\"; Expression = { $_.PSChildName } }, @{Name = \"UserHive\"; Expression = { \"$($_.ProfileImagePath)NTuser.dat\" } }, @{Name = \"UserName\"; Expression = { \"$($_.ProfileImagePath | Split-Path -Leaf)\" } } |\r\n        Where-Object { $ExcludeUsers -notcontains $_.UserName }\r\n    \r\n    # Add in the .DEFAULT User Profile\r\n    $DefaultProfile = \"\" | Select-Object SID, UserHive, UserName\r\n    $DefaultProfile.SID = \".DEFAULT\"\r\n    $DefaultProfile.UserHive = \"C:UsersPublicNTuser.dat\"\r\n    try {\r\n        # Fix for edge case where PSObject is missing the add operator\r\n        $UserProfiles = {\r\n            $UserProfiles | ForEach-Object { $_ }\r\n            $DefaultProfile\r\n        }.Invoke()\r\n    }\r\n    catch {\r\n        Write-Host \"Failed to update default profile, skipping.\"\r\n    }\r\n    \r\n\r\n    # Loop through each profile on the machine\r\n    Foreach ($UserProfile in $UserProfiles) {\r\n        # Load User ntuser.dat if it's not already loaded\r\n        If (($ProfileWasLoaded = Test-Path -Path \"Registry::HKEY_USERS$($UserProfile.SID)\") -eq $false) {\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe LOAD HKU$($UserProfile.SID) $($UserProfile.UserHive)\" -Wait -WindowStyle Hidden\r\n        }\r\n        # Manipulate the registry\r\n        $key = \"Registry::HKEY_USERS$($UserProfile.SID)$($Path)\"\r\n        Set-ItemProp -Path $key -Name $Name -Value $Value\r\n \r\n        # Unload NTuser.dat\r\n        If ($ProfileWasLoaded -eq $false) {\r\n            [gc]::Collect()\r\n            Start-Sleep 1\r\n            Start-Process -FilePath \"cmd.exe\" -ArgumentList \"\/C reg.exe UNLOAD HKU$($UserProfile.SID)\" -Wait -WindowStyle Hidden | Out-Null\r\n        }\r\n    }\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p>Acesse mais de 300 scripts no NinjaOne Dojo<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/freetrialform\/\">Obter acesso<\/a><\/p>\n<\/div>\n<h2>Detalhamento<\/h2>\n<p>O script come\u00e7a definindo par\u00e2metros, permitindo que os usu\u00e1rios desativem ou ativem o Run Dialog e at\u00e9 mesmo excluam usu\u00e1rios espec\u00edficos. Uma fun\u00e7\u00e3o, Set-ItemProp, \u00e9 ent\u00e3o definida para gerenciar a cria\u00e7\u00e3o ou modifica\u00e7\u00e3o de chaves de registro. O processo principal envolve a defini\u00e7\u00e3o do caminho do registro relacionado \u00e0 caixa de di\u00e1logo Executar, a recupera\u00e7\u00e3o de todos os perfis de usu\u00e1rio e o looping de cada perfil para modificar o registro adequadamente.<\/p>\n<h2>Casos de uso em potencial<\/h2>\n<p>Considere uma profissional de TI, Sarah, em uma universidade. Para garantir que os computadores do laborat\u00f3rio sejam usados estritamente para fins acad\u00eamicos, Sarah decide desativar o Run Dialog, excluindo os perfis dos assistentes de laborat\u00f3rio. Esse script permite que Alex alcance esse equil\u00edbrio entre seguran\u00e7a e acessibilidade.<\/p>\n<h2>Compara\u00e7\u00f5es<\/h2>\n<p>Embora a Pol\u00edtica de Grupo ofere\u00e7a uma maneira de desativar a caixa de di\u00e1logo Executar, ela pode n\u00e3o fornecer a granularidade que esse script oferece. A abordagem direta desse script oferece mais agilidade, especialmente em organiza\u00e7\u00f5es maiores.<\/p>\n<h2>Recomenda\u00e7\u00f5es<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.ninjaone.com\/blog\/back-up-and-restore-windows-registry\/\">Fa\u00e7a backup do<\/a> estado <a href=\"https:\/\/www.ninjaone.com\/blog\/back-up-and-restore-windows-registry\/\">atual do registro<\/a> antes de fazer modifica\u00e7\u00f5es.<\/li>\n<li>Teste o script em um ambiente controlado primeiro.<\/li>\n<li>Mantenha a lista de usu\u00e1rios exclu\u00eddos atualizada.<\/li>\n<\/ul>\n<h2>Considera\u00e7\u00f5es finais<\/h2>\n<p>No mundo din\u00e2mico da TI, ferramentas como o NinjaOne oferecem uma <a href=\"https:\/\/www.ninjaone.com\/pt-br\/\">plataforma centralizada para o gerenciamento de TI<\/a>. A integra\u00e7\u00e3o de scripts como o discutido garante que os profissionais de TI permane\u00e7am equipados para lidar com qualquer desafio, especialmente quando se trata de gerenciar recursos como a caixa de di\u00e1logo Executar do Windows.<\/p>\n","protected":false},"author":35,"featured_media":142454,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[12456],"class_list":["post-809287","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub\/809287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/comments?post=809287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media\/142454"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/media?parent=809287"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/operating_system?post=809287"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/pt-br\/wp-json\/wp\/v2\/use_cases?post=809287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}