How to set up AutoPlay when connecting a USB in Windows 11

Last update: 18/09/2025
Author Isaac
  • AutoPlay lets you decide what it does Windows 11 USB and cards: open, import or do nothing.
  • You can manage it from Settings, Control Panel or Policies (gpedit).
  • Developers can register apps for content or device events (WPD).

Setting up AutoPlay in Windows 11

When you connect a USB flash drive, SD card or insert a DVD into Windows 11, the system attempts to identify the type of content and automatically suggests what to do. This feature, known as AutoPlay, can save you time or, if you prefer, can be completely disabled to avoid interruptions and maintain tighter control over what happens when connecting devices.

In the following lines you will see how to activate or deactivate AutoPlay from Settings, the Control panel and group policies. Additionally, if you develop Windows applications, you will learn how to register your app as an AutoPlay option (per content and per device), and even how to treat a volume as AutoPlay device with an autorun.inf file. We'll close with a reference to AutoPlay events so you have a quick look at what triggers each scenario.

What is AutoPlay in Windows 11?

AutoPlay is a Windows 11 feature that automatically displays, opens, or plays content when you connect a removable drive or a memory cardYou can also import photos and videos from cameras or SD cards without any manual steps. It's usually enabled by default, but you can adjust its behavior or disable it completely if you're looking for more control.

The utility goes further: depending on the content detected in the media, Windows may offer different options (for example, open Explorer, ask what to do, or import photos). If you prefer to decide each time, you can have AutoPlay I always asked you when connecting a device or media.

Turn AutoPlay on or off from Settings

The most direct route to managing AutoPlay is in the Windows 11 Settings app. With a couple of clicks you can turn the feature on and choose what to do with drives and cards, or disable it so that Windows does not run anything automatically.

Quick steps: Open Start and go to Settings. In the side panel, go to Bluetooth and devices and select the section Automatic playbackYou'll see a switch called "Use autoplay for all media and devices." If you turn it off, Windows 11 will stop launching actions when connecting USB, SD or disks.

Just below, you can adjust behavior by media typeUnder "Removable Drive" and "Memory Card," you'll find menus with several options. Below are the details for each.

Options for Removable Drive (USB)

Choose what Windows 11 does when you plug in a USB flash drive or external drive. You can ask it to do nothing, open Explorer, or ask you every time. These are the most common options in the Settings section. Removable drive:

  • Take no action: Windows will do nothing when you connect the drive.
  • Open folder to view files: File Explorer will open with the contents of the drive, ideal for quickly reviewing or copying documents.
  • ask me every time: A pop-up menu will appear with the available options each time you connect the device.
  • Configure settings storage: Opens the storage options directly if you prefer to manage your device from that section.

With these choices, you can adapt AutoPlay's behavior to your workflow. If you usually manage files manually, you'll probably want to open Explorer or “Ask me every time.”

Memory Card Options

If you work with cameras or drones, the SD card usually comes with photos and videos. AutoPlay can import them to the Photos app or OneDrive, open Explorer, or let you choose. Typical options include Memory card you'll find:

  • Import photos and videos: Automatically sends pictures and clips to the Windows 11 Photos app or OneDrive to keep them organized.
  • Play: Opens media files with Windows Media Player for immediate viewing.
  • Take no action: : nothing runs when the card is inserted.
  • Open folder to view files: Launches Explorer so you can manually select what you want to copy or review.
  • ask me every time: Displays a prompt with the options available each time the card is inserted.
  5 Best Newspaper Layout Software for Professional Journalists

As you can see, the range of options ranges from automating photo imports to maintaining full control. You decide how much you want. Windows 11 intervenes upon detecting the content.

Change AutoPlay from the Control Panel

If you prefer the classic approach, it is possible to configure AutoPlay from the Control panelThe result is equivalent, but with an even more granular listing by media type and default application.

Open the Control Panel from Start and go to “Hardware and Sound.” Inside, select “AutoPlay.” In this window, you can select or unselect “Use AutoPlay for all media and devices,” and also assign the default app or action for each type of media.

When you're done, don't forget to click “Save” to apply the changesIf you change your mind, you can always come back here to adjust any format or device.

Controlling AutoPlay with the Policy Editor (gpedit)

In Windows 11 editions that include the Local Group Policy Editor, you can manage AutoPlay using policies. This is very useful in corporate environments or for fine-tuning the to maximise security and your enjoyment. on shared computers.

Seeks "gpedit” from Start and go to Computer Configuration > Administrative Templates > Windows Components > AutoPlay Policies. Enter the “Turn off AutoPlay” policy.

If the policy is set to “Not Configured” or “Disabled,” AutoPlay is enabled. If you set it to “Enabled,” you can choose which drives to disallow autoplay from the “Disable autoplay on” dropdown (e.g., all drives). Apply and accept to consolidate the policy in the team.

AutoPlay for Developers: Register Your App for Content Events

Windows allows UWP apps to register themselves as options when AutoPlay detects content on a device. costumes (USB, SD card, DVD). This happens, for example, when inserting an SD card with a camera structure (DCIM, AVCHD, or PRIVATE\ACHD), the ShowPicturesOnArrival event is generated and the system suggests compatible apps.

In addition, AutoPlay also integrates with proximity sharing (tap/send) between PCs. In that case, when activating files, the property Files of FileActivatedEventArgs includes the root folder that groups the shared. Here you have a step by step guide to register your app as a content-based AutoPlay option.

Step 1: Create project and add AutoPlay declarations (content)

In Visual Studio, create a “Blank UWP App (.NET Native)” and open the manifest (Package.appxmanifest). On the Capabilities tab, enable Removable storage and, if you are going to work with local images, the Image Library. Under Declarations, add “Self-Playing Content.”

Define the Start Actions for the content event you want to handle. For cameras (DCIM, AVCHD, or PRIVATE\ACHD structure), AutoPlay launches ShowPicturesOnArrivalYou can configure multiple actions (e.g., display or copy) differentiated by the Verb field. Then, associate file types (.jpg and .png) in “File Type Associations” so AutoPlay filters correctly.

Example values for two start actions on the same ShowPicturesOnArrival event:

Configuration Price
Verb Show
Visible name Show images
Content event ShowPicturesOnArrival
Configuration Price
Verb copy
Visible name Copy images to the library
Content event ShowPicturesOnArrival

The display name is what the user will see in the AutoPlay menu, and the Verb This is the identifier your app will receive to know which option it chose (avoid using “open”, which is reserved by the system).

Step 2: Add Minimal XAML UI

Prepare a simple interface for listing files and displaying images. For example, in MainPage.xaml you can include a text block and a canvas for drawing thumbnails or previews.

<TextBlock FontSize="18">File List</TextBlock>
<TextBlock x:Name="FilesBlock" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,20,0,0" Height="280" Width="240" />
<Canvas x:Name="FilesCanvas" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="260,20,0,0" Height="280" Width="100"/>

With this base you will be able to list names and render thumbnails in a Canvas in a simple way to validate the AutoPlay flow.

Step 3: Check the Verb on Activation

In App.xaml.cs, override OnFileActivated. Check args.Verb and call the corresponding routine to display or copy. AutoPlay switches to Boot the root folder of the storage (first item of Files).

protected override void OnFileActivated(FileActivatedEventArgs args)
{
    if (args.Verb == "show")
    {
        Frame rootFrame = (Frame)Window.Current.Content;
        MainPage page = (MainPage)rootFrame.Content;
        page.DisplayImages((Windows.Storage.StorageFolder)args.Files);
    }
    if (args.Verb == "copy")
    {
        Frame rootFrame = (Frame)Window.Current.Content;
        MainPage page = (MainPage)rootFrame.Content;
        page.CopyImages((Windows.Storage.StorageFolder)args.Files);
    }
    base.OnFileActivated(args);
}

This distinction by verb allows the same app to offer several actions in the AutoPlay panel and execute the appropriate logic.

  Easy Ways to Turn Off Alarm Clock Ringer on iPhone

Step 4: Display images from DCIM

In MainPage.xaml.cs, implement DisplayImages to traverse the first folder within DCIM, list files, and draw thumbnails on the screen. This pattern serves as an example of asynchronous file access on removable storage.

async internal void DisplayImages(Windows.Storage.StorageFolder rootFolder)
{
    var dcimFolder = await rootFolder.GetFolderAsync("DCIM");
    var folderList = await dcimFolder.GetFoldersAsync();
    var cameraFolder = folderList;
    var fileList = await cameraFolder.GetFilesAsync();
    for (int i = 0; i < fileList.Count; i++)
    {
        var file = (Windows.Storage.StorageFile)fileList;
        WriteMessageText(file.Name + "\n");
        DisplayImage(file, i);
    }
}

async private void DisplayImage(Windows.Storage.IStorageItem file, int index)
{
    try
    {
        var sFile = (Windows.Storage.StorageFile)file;
        Windows.Storage.Streams.IRandomAccessStream imageStream = await sFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
        Windows.UI.Xaml.Media.Imaging.BitmapImage imageBitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
        imageBitmap.SetSource(imageStream);
        var element = new Image();
        element.Source = imageBitmap;
        element.Height = 100;
        Thickness margin = new Thickness();
        margin.Top = index * 100;
        element.Margin = margin;
        FilesCanvas.Children.Add(element);
    }
    catch (Exception e)
    {
        WriteMessageText(e.Message + "\n");
    }
}

private Windows.UI.Core.CoreDispatcher messageDispatcher = Window.Current.CoreWindow.Dispatcher;
private async void WriteMessageText(string message, bool overwrite = false)
{
    await messageDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
    {
        if (overwrite) FilesBlock.Text = message;
        else FilesBlock.Text += message;
    });
}

The UI logic is simple, but enough to verify that your app reacts to the event. ShowPicturesOnArrival and represents storage elements.

Step 5: Copy images to the library

For the "copy" option, create a folder in the Image Library and duplicate the found files there. Asynchronous calls simplify copying without blocking the interface.

async internal void CopyImages(Windows.Storage.StorageFolder rootFolder)
{
    var dcimFolder = await rootFolder.GetFolderAsync("DCIM");
    var folderList = await dcimFolder.GetFoldersAsync();
    var cameraFolder = folderList;
    var fileList = await cameraFolder.GetFilesAsync();
    try
    {
        var folderName = "Images " + DateTime.Now.ToString("yyyy-MM-dd HHmmss");
        Windows.Storage.StorageFolder imageFolder = await Windows.Storage.KnownFolders.PicturesLibrary.CreateFolderAsync(folderName);
        foreach (Windows.Storage.IStorageItem file in fileList)
        {
            CopyImage(file, imageFolder);
        }
    }
    catch (Exception e)
    {
        WriteMessageText("Failed to copy images.\n" + e.Message + "\n");
    }
}

async internal void CopyImage(Windows.Storage.IStorageItem file, Windows.Storage.StorageFolder imageFolder)
{
    try
    {
        Windows.Storage.StorageFile sFile = (Windows.Storage.StorageFile)file;
        await sFile.CopyAsync(imageFolder, sFile.Name);
        WriteMessageText(sFile.Name + " copied.\n");
    }
    catch (Exception e)
    {
        WriteMessageText("Failed to copy file.\n" + e.Message + "\n");
    }
}

With this, your application will be ready to act as an AutoPlay option for content and automate copying or viewing.

Register the app for device events (WPD\ImageSource)

In addition to the “content” events, AutoPlay emits “device” events. A typical case is registering your app as an option when a device is connected. camera which presents itself as “ImageSource” via MTP (Windows Portable Devices). In that scenario, the relevant event is WPD\ImageSource.

Create another UWP, enable the "Removable Storage" capability, and add "AutoPlay Device" in Declarations. Define a launch action with a Verb and display name, and specify WPD\ImageSource as the event. Then, add file type associations (e.g., .jpg and .png) to filter what your app handles.

Configuration Price
Verb Show
Visible name Show images
Device event WPD\ImageSource

These APIs depend on the desktop device family. Make sure to add the reference to “Windows Desktop Extensions for UWP” in your project to be able to use Windows.Devices.Portable.StorageDevice.

UI XAML and Device Activation

To display thumbnails, you can use a templated ListView and a tiled panel. In App.xaml.cs, intercept OnActivated and if args.Kind is Device, use StorageDevice.FromId with the received DeviceInformationId to access the storage.

protected override void OnActivated(IActivatedEventArgs args)
{
    if (args.Kind == ActivationKind.Device)
    {
        Frame rootFrame = null;
        if (Window.Current.Content == null)
        {
            rootFrame = new Frame();
            rootFrame.Navigate(typeof(MainPage));
            Window.Current.Content = rootFrame;
        }
        else
        {
            rootFrame = Window.Current.Content as Frame;
        }
        Window.Current.Activate();

        bool storageDeviceAPIPresent = Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Devices.Portable.StorageDevice");
        if (storageDeviceAPIPresent)
        {
            var mPage = rootFrame.Content as MainPage;
            var deviceArgs = args as DeviceActivatedEventArgs;
            if (deviceArgs != null)
            {
                mPage.ShowImages(Windows.Devices.Portable.StorageDevice.FromId(deviceArgs.DeviceInformationId));
            }
        }
        else
        {
            // API no disponible en familias no escritorio
        }
    }
    base.OnActivated(args);
}

Once you have the root folder, you can extract data from the device (name, type, etc.) and browse subfolders to build the list of images with its thumbnails, making asynchronous calls in sequence so as not to saturate the device.

Treat a volume as an “AutoPlay device” with autorun.inf (CustomEvent)

If you need a volume (for example, a USB stick with your app) to be identified as a “device” for AutoPlay, you can include a autorun.inf file in the root and add the CustomEvent key. This way, when you connect the volume, AutoPlay will generate a custom device event with that name.

  The camera cannot establish connection

Create the file in the middle root with this content:


CustomEvent=AutoPlayCustomEventQuickstart

Next, in your UWP app, enable “Removable Storage” and register a declaration of AutoPlay Content for that event (the ContentEvent value must match the CustomEvent value). Also add any file type associations you need (e.g., .ms) to filter the content.

Configuration Price
Verb Show
Visible name show files
Content event AutoPlayCustomEventQuickstart

In OnFileActivated, AutoPlay will pass the device's root folder in args.Files. From there you can list and work with files that meet the filter definite.

protected override void OnFileActivated(FileActivatedEventArgs args)
{
    var rootFrame = Window.Current.Content as Frame;
    var page = rootFrame.Content as MainPage;
    page.DisplayFiles(args.Files as Windows.Storage.StorageFolder);
    base.OnFileActivated(args);
}

A simple implementation to display files with a specific extension could use a query with QueryOptions and CreateFileQueryWithOptions to retrieve compatible items.

AutoPlay Event Reference

AutoPlay can log and trigger events based on the type of device connected or the content detected. Below is a referencia of the most common scenarios and the associated event in Windows:

Scenario Event Description
On-Camera Photos (WPD) WPD\ImageSource For cameras that are presented as devices portable and offer ImageSource functionality.
Music in player (WPD) WPD\AudioSource Players that expose AudioSource via Windows Portable Devices.
Video on camcorder (WPD) WPD\VideoSource Video devices with VideoSource functionality under WPD.
Connected drive or volume StorageOnArrival Launched when a drive/volume is connected. If there is DCIM/AVCHD/PRIVATE\ACHD in the root directory, ShowPicturesOnArrival takes precedence.
Images from mass storage (legacy) ShowPicturesOnArrival It is triggered when the volume contains typical camera folders or, if the user enables “Choose what to do,” when it detects photos in the root.
Photos received by proximity ShowPicturesOnArrival When sharing by proximity, if images are detected among the files, this event is generated.
Music from mass storage (legacy) PlayMusicFilesOnArrival With “Choose what to do,” if AutoPlay finds music, it triggers the music event upon arrival.
Music by proximity PlayMusicFilesOnArrival If tracks are shared by proximity, the corresponding music event occurs.
Video from mass storage (legacy) PlayVideoFilesOnArrival Detects video files and fires the event to play videos when the media is connected.
Proximity video PlayVideoFilesOnArrival It is issued if the files shared by proximity are of the video type.
Mixed content MixedContentOnArrival When no dominant type is identified (e.g., images), AutoPlay fires the mixed content event.
Video on optical media PlayDVDArrival, PlayBluRayOnArrival, PlayVideoCDMovieOnArrival, PlaySuperVideoCDMovieOnArrival Insertion of discs with video content; the event is generated according to the type of optical media.
Music on optical media PlayCDAudioOnArrival, PlayDVDAudioOnArrival For optical discs with audio, AutoPlay selects the appropriate event.
“Enhanced” discs PlayEnhancedCDOnArrival, PlayEnhancedDVDOnArrival When detecting discs with data and media tracks, it triggers the enhanced editing event.
Optical disc recording HandleCDBurningOnArrival, ManageDVDBurningOnArrival, ManageBDBurningOnArrival For recordable media, AutoPlay offers to manage the recording.
Unknown content UnknownContentOnArrival Fallback for unsupported cases. It's not recommended to register the app only for this event.

Finally, remember that you can add the corresponding extension in the package.appxmanifest to register your app for a specific AutoPlay event. An example for ShowPicturesOnArrival would be:

<Applications>
  <Application>
    <Extensions>
      <Extension Category="windows.autoPlayContent">
        <AutoPlayContent>
          <LaunchAction Verb="show" ActionDisplayName="Show Pictures" ContentEvent="ShowPicturesOnArrival" />
        </AutoPlayContent>
      </Extension>
    </Extensions>
  </Application>
</Applications>

With all of the above, you can decide whether you want Windows 11 to act for you when connecting drives and cards, or if you prefer a manual approach. And if you create software, you have the ability to integrate your enforcement in the AutoPlay stream by both content and device.

autoplay windows 11
Related article:
How to disable AutoPlay in Windows step by step