Como desativar a execução automática no Windows: Um script do PowerShell para profissionais de TI e MSPs

Na vasta extensão da tecnologia empresarial moderna, os profissionais de TI e os provedores de serviços gerenciados (MSPs) lidam constantemente com preocupações de segurança. Uma tarefa simples, mas crucial, como a desativação do recurso Autorun (Autoplay) nas unidades do Windows, pode ser um divisor de águas para melhorar a segurança do sistema. Para aqueles que estão procurando um eficiente “script de desativação de execução automática”, não procurem mais. A seguir, vamos nos aprofundar em um script do PowerShell que faz exatamente isso e discutir suas implicações para profissionais de TI e MSPs.

Entendendo o script “Disable Autorun” (Desativar execução automática)

Esse script do PowerShell tem uma finalidade simples: desativar o recurso Autorun ou Autoplay em todas as unidades do Windows.

Breve sinopse do roteiro:

  • O que ele faz: Desativa a execução automática (Autoplay) em todas as unidades.
  • Requisitos: Windows 10 ou Windows Server 2016 e superior, PowerShell v5.1
  • Uso: A execução é bastante simples: PS C:> Disable-Autorun.ps1

O roteiro

#Requires -Version 5.1

<#
.SYNOPSIS
    Disables Autorun(Autoplay) on all drives.
.DESCRIPTION
    Disables Autorun(Autoplay) on all drives.
.EXAMPLE
    No parameters needed.
.EXAMPLE
    PS C:> Disable-Autorun.ps1
    No parameters needed.
.OUTPUTS
    None
.NOTES
    Minimum OS Architecture Supported: Windows 10, Windows Server 2016
    Release Notes:
    Initial Release
By 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.
    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. 
    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. 
    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. 
    Warranty Disclaimer: The script is provided “as is” and “as available”, 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. 
    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. 
    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. 
    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).
.COMPONENT
    DataIOSecurity
#>

[CmdletBinding()]
param ()

begin {
    function Test-IsElevated {
        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
        $p = New-Object System.Security.Principal.WindowsPrincipal($id)
        if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
        { Write-Output $true }
        else
        { Write-Output $false }
    }
    function Set-ItemProp {
        param (
            $Path,
            $Name,
            $Value,
            [ValidateSet("DWord", "QWord", "String", "ExpandedString", "Binary", "MultiString", "Unknown")]
            $PropertyType = "DWord"
        )
        New-Item -Path $Path -Force | Out-Null
        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {
            Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false | Out-Null
        }
        else {
            New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false | Out-Null
        }
    }
}
process {
    if (-not (Test-IsElevated)) {
        Write-Error -Message "Access Denied. Please run with Administrator privileges."
        exit 1
    }
    $Path = 'HKLM:SOFTWAREMicrosoftWindowsCurrentVersionpoliciesExplorer'
    $Name = "NoDriveTypeAutorun"
    $Value = 0xFF
    # Sets NoDriveTypeAutorun to 0xFF
    Set-ItemProp -Path $Path -Name $Name -Value $Value
}
end {}

 

Acesse mais de 300 scripts no NinjaOne Dojo

Obter acesso

Por que desativar o Autorun é importante

  • Risco minimizado de malware: O Autorun, quando ativado, pode permitir que softwares nocivos sejam executados automaticamente a partir de USBs ou outras unidades externas. Ao desativar esse recurso, o script ajuda a reduzir o risco de propagação de malware nos sistemas em rede.
  • Experiência do usuário simplificada: Para a TI e os MSPs que gerenciam grandes sistemas em rede, é fundamental manter uma experiência de usuário consistente. A eliminação de pop-ups inesperados do Autorun ou de inicializações automáticas de software contribui para essa consistência.
  • Fácil implementação: O “script de desativação de execução automática” fornecido pode ser facilmente implantado em vários sistemas em um ambiente corporativo, o que o torna uma ferramenta avançada para o gerenciamento de sistemas em massa.

Os possíveis riscos de desativar o Autorun

  • Os usuários talvez não consigam executar arquivos executáveis de unidades USB.
  • Os usuários podem ter que abrir manualmente cada arquivo em uma unidade USB.
  • Alguns softwares podem não funcionar corretamente se o Autorun estiver desativado.

Outras maneiras de desativar o Autorun

Por meio do Registro do Windows:

  • Abra o Editor do Registro.
  • Navegue até a chave a seguir: HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer
  • Clique duas vezes no valor NoDriveAutoRun.
  • Defina o valor como 1 para desativar a execução automática para todas as unidades.
  • Defina o valor como 2 para desativar o Autorun somente para unidades removíveis.

Por meio da Política de Grupo:

  • Abra o Console de gerenciamento de política de grupo.
  • Navegue até a seguinte configuração de política:
  • Configuração do computadorModelos administrativosComponentes do WindowsAutoplay
  • Defina a política como Disabled para desativar a execução automática em todas as unidades.
  • Defina a política como Enabled para desativar o Autorun somente para unidades removíveis.

Considerações finais

No mundo em rápida evolução da TI, às vezes são os scripts simples que podem causar o impacto mais significativo. Se você é um profissional de TI, um MSP ou um técnico curioso, é essencial ter ferramentas como o “script de desativação de reprodução automática” em seu arsenal. Afinal de contas, em um mundo repleto de ameaças à segurança cibernética, são as precauções básicas, como a desativação da execução automática em uma unidade, que geralmente se mostram mais cruciais.

Próximas etapas

Montar uma equipe de TI eficaz requer uma solução centralizada que seja a principal ferramenta de entrega de serviços. Com NinjaOne, a TI monitora, gerencia, protege e oferece suporte a todos os dispositivos, onde quer que estejam, dispensando infraestrutura complexa no local.

Saiba mais sobre a solução NinjaOne Remote Script Deployment, agende uma demonstração, ou inicie sua avaliação gratuita da plataforma NinjaOne.

Categories:

You might also like

Como desativar a atualização automática do Windows 11 [Script do PowerShell]

Como verificar se há um arquivo de hosts modificado com o PowerShell

Como garantir que a autenticação moderna esteja ativada no Office 365 com o PowerShell

Automatize o gerenciamento de ferramentas administrativas no Windows com este script essencial do PowerShell

Identificação e gerenciamento de contas locais não utilizadas em sistemas Windows

Script do PowerShell para identificar conexões Ethernet lentas no Windows

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • 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.
  • 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.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, 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.
  • 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.
  • 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.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).