Disabling Autorun and Auto Play

Fahrid F 201 Reputation points
2020-12-09T03:34:35.193+00:00

Hi

I am looking for the powershell commands for the below procedure.

Please let me know if you have any commands to execute the same.

  1. Press the Windows+ R to openthe Run box. Type gpmc.msc and press Enter.
  2. In the left pane, browse to Domains under the AD Forest.
  3. Browse for the domain. Right-click the domain and select Create a GPO in this domain, and Link it here.
  4. Enter a name for the new domain GPO, for example Autoplay_gpo. Select Source Starter GPO: (none). Click OK.
  5. In the left pane, right-click the new domain GPO and select Edit , close the pop-up window if appears.
  6. In the Group Policy Management window, browse to Computer Configuration > Policies > Administrative Templates > Windows Components > AutoPlay Policies.
  7. Under AutoPlayPolicies, click Turnoff AutoPlay, toggle the policytoEnabled and set options to All Drives. Click Apply and click Ok.
  8. Click on Set the Default Behavior for AutoRun, toggle the policy to Enabled and set the default behavior to Do Not Execute Any AutoRun Commands. Click Apply and click Ok.
  9. Close the Group Policy Management window.
  10. Press the Windows key + R to open the Run box. Type CMD and press Enter.
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2020-12-09T10:11:35.74+00:00

    Hi,

    Please see if this works for you. Replace "DC=contoso, DC=com" with your own domain.

    New-GPO -Name Autoplay_gpo | New-GPLink -Target "DC=contoso, DC=com"  
    Set-GPRegistryValue -Name "Autoplay_gpo" -Key "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -ValueName NoDriveTypeAutorun -Type DWord -Value 255  
    Set-GPRegistryValue -Name "Autoplay_gpo" -Key "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -ValueName NoAutorun -Type DWord -Value 1  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.