{"id":208622,"date":"2024-01-31T12:52:32","date_gmt":"2024-01-31T12:52:32","guid":{"rendered":"https:\/\/www.ninjaone.com\/script-hub\/cuadro-de-dialogo-ejecutar-de-windows\/"},"modified":"2024-03-04T18:43:03","modified_gmt":"2024-03-04T18:43:03","slug":"cuadro-de-dialogo-ejecutar-de-windows","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/cuadro-de-dialogo-ejecutar-de-windows\/","title":{"rendered":"C\u00f3mo desactivar o activar el cuadro de di\u00e1logo Ejecutar de Windows con PowerShell"},"content":{"rendered":"<p>En el intrincado mundo de las TI, gestionar el acceso de los usuarios a determinadas funciones del sistema es de suma importancia. Una de estas funciones es el cuadro de di\u00e1logo Ejecutar de Windows. Pero, \u00bfpor qu\u00e9 los profesionales de TI podr\u00edan querer restringir el acceso? Esta gu\u00eda profundiza en el <strong>script PowerShell dise\u00f1ado para controlar la accesibilidad del cuadro de di\u00e1logo Ejecutar<\/strong> y las implicaciones de dichas acciones.<\/p>\n<h2>Panor\u00e1mica del cuadro de di\u00e1logo Ejecutar de Windows<\/h2>\n<ul>\n<li>\n<h3>\u00bfQu\u00e9 es el cuadro de di\u00e1logo Ejecutar de Windows?<\/h3>\n<ul>\n<li>El cuadro de di\u00e1logo Ejecutar de Windows es una funci\u00f3n que proporciona a los usuarios una forma r\u00e1pida de iniciar programas, abrir carpetas y ejecutar comandos del sistema. Al pulsar Windows + R, aparece un peque\u00f1o cuadro de di\u00e1logo que permite a los usuarios escribir directamente los comandos.<\/li>\n<\/ul>\n<\/li>\n<li>\n<h3>\u00bfC\u00f3mo se utiliza el cuadro de di\u00e1logo Ejecutar de Windows?<\/h3>\n<ul>\n<li>Se utiliza principalmente para un acceso r\u00e1pido. En lugar de navegar por m\u00faltiples men\u00fas o carpetas, los usuarios pueden simplemente escribir un comando o una ruta en el cuadro de di\u00e1logo Ejecutar de Windows para iniciar instant\u00e1neamente un programa o abrir un directorio.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"in-context-cta\"><h2>La opini\u00f3n de Gavin<\/h2>\n<p style=\"text-align: left;\">El cuadro de di\u00e1logo Ejecutar es uno de los principales lugares a los que la gente acude si quiere acceder o ejecutar comandos en el sistema en general. Como punto principal para ejecutar comandos y programas, bloquearlo presenta un entorno m\u00e1s controlado y reduce significativamente el riesgo.<\/p>\n<p style=\"text-align: left;\">Aunque no es el \u00fanico punto de ejecuci\u00f3n de comandos y programas, es el m\u00e1s utilizado por las personas que no tienen necesariamente experiencia en la administraci\u00f3n de sistemas. Este bloqueo debe utilizarse en combinaci\u00f3n con otras restricciones de seguridad (como impedir el acceso al registro o al s\u00edmbolo del sistema).<\/p>\n<\/div>\n<h2>Consecuencias para la seguridad de desactivar el cuadro de di\u00e1logo Ejecutar de Windows<\/h2>\n<h3>\u00bfCu\u00e1les son los riesgos?<\/h3>\n<p>Desactivar el cuadro de di\u00e1logo Ejecutar puede obstaculizar involuntariamente la productividad. Algunos usuarios avanzados conf\u00edan en el cuadro de di\u00e1logo Ejecutar para realizar tareas r\u00e1pidas y gestionar el sistema. Adem\u00e1s, si no se hace correctamente, la manipulaci\u00f3n de los ajustes del sistema puede provocar otros problemas no deseados.<\/p>\n<h3>\u00bfCu\u00e1les son las ventajas?<\/h3>\n<p>La principal ventaja es una mayor seguridad. Desactivar el cuadro de di\u00e1logo Ejecutar de Windows puede evitar acciones no autorizadas o malintencionadas, especialmente por parte de usuarios poco versados en el funcionamiento del sistema. Adem\u00e1s, reduce el riesgo de cambios accidentales o la ejecuci\u00f3n de comandos da\u00f1inos.<\/p>\n<h3>\u00bfC\u00f3mo reducir los riesgos?<\/h3>\n<p>Antes de aplicar cualquier cambio, es fundamental:<\/p>\n<ul>\n<li>Comunicarse con los usuarios, especialmente con los que puedan verse afectados por el cambio.<\/li>\n<li>Proporcionar m\u00e9todos o herramientas alternativos para tareas que antes se realizaban mediante el cuadro de di\u00e1logo Ejecutar de Windows.<\/li>\n<li>Asegurarse de que existe una forma de revertir r\u00e1pidamente los cambios en caso necesario.<\/li>\n<\/ul>\n<h2>Antecedentes<\/h2>\n<p>El script PowerShell proporcionado es una herramienta s\u00f3lida para que los profesionales de TI y los proveedores de servicios gestionados (MSP) controlen la accesibilidad del cuadro de di\u00e1logo Ejecutar. En los entornos en los que la seguridad es una prioridad absoluta, estas herramientas se vuelven indispensables. La capacidad del script para excluir a usuarios espec\u00edficos de estas restricciones a\u00f1ade una capa de flexibilidad, garantizando que el acceso necesario no se revoque por completo.<\/p>\n<h2>El script para desactivar la recopilaci\u00f3n de datos de Windows 10<\/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>Accede a m\u00e1s de 300 scripts en el Dojo de NinjaOne<\/p>\n<p><a href=\"https:\/\/www.ninjaone.com\/es\/prueba-gratuita-formulario\/\">Obt\u00e9n acceso<\/a><\/p>\n<\/div>\n<h2>An\u00e1lisis detallado<\/h2>\n<p>El script comienza estableciendo par\u00e1metros, permitiendo a los usuarios desactivar o activar el cuadro de di\u00e1logo Ejecutar e incluso excluir a usuarios espec\u00edficos. A continuaci\u00f3n, se define una funci\u00f3n, Set-ItemProp, para gestionar la creaci\u00f3n o modificaci\u00f3n de claves de registro. El proceso principal consiste en definir la ruta del registro relacionada con el cuadro de di\u00e1logo Ejecutar de Windows, recuperar todos los perfiles de usuario y, a continuaci\u00f3n, recorrer cada perfil para modificar el registro en consecuencia.<\/p>\n<h2>Posibles casos de uso<\/h2>\n<p>Imaginemos a Sara, profesional de TI en una universidad. Para garantizar que los ordenadores del laboratorio se utilicen estrictamente con fines acad\u00e9micos, Sara decide desactivar el cuadro de di\u00e1logo Ejecutar de Windows, excluyendo los perfiles de los ayudantes de laboratorio. Este script para desactivar el cuadro de di\u00e1logo Ejecutar permite a Sara lograr este equilibrio entre seguridad y accesibilidad.<\/p>\n<h2>Comparaciones<\/h2>\n<p>Aunque la directiva de grupo ofrece una forma de desactivar el cuadro de di\u00e1logo Ejecutar de Windows, puede que no proporcione la granularidad que ofrece este script. El enfoque directo de este script ofrece m\u00e1s agilidad, especialmente en las grandes organizaciones.<\/p>\n<h2>Preguntas frecuentes<\/h2>\n<ul>\n<li>\u00bfPuedo utilizar este script para desactivar el cuadro de di\u00e1logo Ejecutar de Windows para excluir a varios usuarios?<br \/>\nS\u00ed, es posible excluir varios usuarios mediante el par\u00e1metro -ExcludeUsers.<\/li>\n<li>\u00bfEs necesario reiniciar el sistema despu\u00e9s de ejecutar el script?<br \/>\nS\u00ed, un reinicio asegura que los cambios se apliquen.<\/li>\n<\/ul>\n<h2>Recomendaciones<\/h2>\n<ul>\n<li>Haz una copia de seguridad del estado actual del registro antes de realizar modificaciones<\/li>\n<li>Prueba el script en un entorno controlado primero.<\/li>\n<li>Mant\u00e9n actualizada la lista de usuarios excluidos.<\/li>\n<\/ul>\n<h2>Reflexiones finales<\/h2>\n<p>En el din\u00e1mico mundo de las TI, herramientas como NinjaOne ofrecen una <a href=\"https:\/\/www.ninjaone.com\/es\/\">plataforma centralizada para la gesti\u00f3n de TI<\/a>. La integraci\u00f3n de scripts como el que hemos visto garantiza que los profesionales de TI est\u00e9n preparados para afrontar cualquier reto, especialmente cuando se trata de gestionar funciones como el cuadro de di\u00e1logo Ejecutar de Windows.<\/p>\n","protected":false},"author":35,"featured_media":207090,"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":[4265],"class_list":["post-208622","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows","use_cases-configuracion-del-sistema"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/208622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/comments?post=208622"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media\/207090"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=208622"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=208622"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=208622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}