<p>I can display and select a single file in windows explorer like this:</p>
<pre><code>explorer.exe /select, &quot;c:\path\to\file.txt&quot;
</code></pre>
<p>However, I can't work out how to select more than one file. None of the permutations of select I've tried work.</p>
<p>Note: I looked at these pages for docs, neither helped.</p>
<p><a href="https://support.microsoft.com/kb/314853" rel="nofollow noreferrer">https://support.microsoft.com/kb/314853</a><br />
<a href="http://web.archive.org/web/20100716112458/http://www.infocellar.com:80/Win98/explorer-switches.htm" rel="nofollow noreferrer">http://web.archive.org/web/20100716112458/http://www.infocellar.com:80/Win98/explorer-switches.htm</a></p>

[{'answer_id': 9359, 'author': 'Nick Berardi', 'author_id': 17, 'author_profile': 'https://Stackoverflow.com/users/17', 'pm_score': 2, 'selected': False, 'text': '<p>it cannot be done through explorer.exe</p>\n'}, {'answer_id': 9497, 'author': 'bruceatk', 'author_id': 791, 'author_profile': 'https://Stackoverflow.com/users/791', 'pm_score': 2, 'selected': False, 'text': '<p>Depending on what you actually want to accomplish you may be able to do it with <a href="http://www.autohotkey.com/" rel="nofollow noreferrer">AutoHotKey</a>.  It is an amazing free tool for automating things you normally can\'t do. It should come with Windows. This script will select your file and highlight the next two files below it when you hit F12.</p>\n\n<pre><code>F12:: \n run explorer.exe /select`, "c:\\path\\to\\file.txt"\n SendInput {Shift Down}{Down}{Down}{Shift Up}\nreturn\n</code></pre>\n\n<p>It is also possible to just put those two middle lines in a text file and then pass it is a parm to autohotkey.exe.  They have an option to compile the script also, which would make it a standalone exe that you could call.  Works great with a great help file.  </p>\n\n<p>@Orion, It is possible to use autohotkey from C#.  You can make an autohotkey script into a standalone executable (about 400k) that can be launched by your C# app (just the way you are launching explorer).  You can also pass it command line parameters.  It does not have any runtime requirements.</p>\n'}, {'answer_id': 13920, 'author': 'Orion Edwards', 'author_id': 234, 'author_profile': 'https://Stackoverflow.com/users/234', 'pm_score': 1, 'selected': False, 'text': "<blockquote>\n  <p>This is one of those questions where it may be good to consider what you're trying to achieve, and whether there's a better method.</p>\n</blockquote>\n\n<p>To add some more context - \nOur company develops a C# client application, which allows users to load files and do stuff with them, kind of like how iTunes manages your MP3 files without showing you the actual file on disk.</p>\n\n<p>It's useful to select a file in the application, and do a 'Show me this file in Windows Explorer` command - this is what I'm trying to achieve, and have done so for single files.</p>\n\n<p>We have a ListView which allows users to select multiple files within the application, and move/delete/etc them. It would be nice to have this 'show me this file in windows' command work for multiple selected files - at least if all the source files are in the same directory, but if it's not possible then it's not a major feature.</p>\n"}, {'answer_id': 233129, 'author': 'PhiLho', 'author_id': 15459, 'author_profile': 'https://Stackoverflow.com/users/15459', 'pm_score': 0, 'selected': False, 'text': '<p>I suppose you can use <code>FindWindowEx</code> to get the SysListView32 of Windows Explorer, then use <code>SendMessage</code> with <code>LVM_SETITEMSTATE</code> to select the items. The difficulty being to know the position of the items... Perhaps <code>LVM_FINDITEM</code> can be used for this.</p>\n'}, {'answer_id': 339174, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Grr i would like to do this as well.  Media Player does it when you select 2+ files and right click and do "open file location" but not exactly sure how (nor do i really feel like spending the time w/ procmon to figure it out).</p>\n'}, {'answer_id': 3011284, 'author': 'flashk', 'author_id': 25149, 'author_profile': 'https://Stackoverflow.com/users/25149', 'pm_score': 5, 'selected': True, 'text': '<p>This should be possible with the shell function <a href="http://msdn.microsoft.com/en-us/library/bb762232(VS.85).aspx" rel="noreferrer"><code>SHOpenFolderAndSelectItems</code></a></p>\n\n<p><strong>EDIT</strong></p>\n\n<p>Here is some sample code showing how to use the function in C/C++, without error checking:</p>\n\n<pre><code>//Directory to open\nITEMIDLIST *dir = ILCreateFromPath(_T("C:\\\\"));\n\n//Items in directory to select\nITEMIDLIST *item1 = ILCreateFromPath(_T("C:\\\\Program Files\\\\"));\nITEMIDLIST *item2 = ILCreateFromPath(_T("C:\\\\Windows\\\\"));\nconst ITEMIDLIST* selection[] = {item1,item2};\nUINT count = sizeof(selection) / sizeof(ITEMIDLIST);\n\n//Perform selection\nSHOpenFolderAndSelectItems(dir, count, selection, 0);\n\n//Free resources\nILFree(dir);\nILFree(item1);\nILFree(item2);\n</code></pre>\n'}, {'answer_id': 3576444, 'author': 'Siarhei Kuchuk', 'author_id': 212746, 'author_profile': 'https://Stackoverflow.com/users/212746', 'pm_score': 3, 'selected': False, 'text': '<p>The true way of selecting multiple files in Explorer is the next</p>\n\n<p>Unmanaged code looks like this (compiled from China code posts with fixing its bugs)</p>\n\n<pre><code>static class NativeMethods\n{\n    [DllImport("shell32.dll", ExactSpelling = true)]\n    public static extern int SHOpenFolderAndSelectItems(\n        IntPtr pidlFolder,\n        uint cidl,\n        [In, MarshalAs(UnmanagedType.LPArray)] IntPtr[] apidl,\n        uint dwFlags);\n\n    [DllImport("shell32.dll", CharSet = CharSet.Auto)]\n    public static extern IntPtr ILCreateFromPath([MarshalAs(UnmanagedType.LPTStr)] string pszPath);\n\n    [ComImport]\n    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\n    [Guid("000214F9-0000-0000-C000-000000000046")]\n    public interface IShellLinkW\n    {\n        [PreserveSig]\n        int GetPath(StringBuilder pszFile, int cch, [In, Out] ref WIN32_FIND_DATAW pfd, uint fFlags);\n\n        [PreserveSig]\n        int GetIDList([Out] out IntPtr ppidl);\n\n        [PreserveSig]\n        int SetIDList([In] ref IntPtr pidl);\n\n        [PreserveSig]\n        int GetDescription(StringBuilder pszName, int cch);\n\n        [PreserveSig]\n        int SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);\n\n        [PreserveSig]\n        int GetWorkingDirectory(StringBuilder pszDir, int cch);\n\n        [PreserveSig]\n        int SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);\n\n        [PreserveSig]\n        int GetArguments(StringBuilder pszArgs, int cch);\n\n        [PreserveSig]\n        int SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);\n\n        [PreserveSig]\n        int GetHotkey([Out] out ushort pwHotkey);\n\n        [PreserveSig]\n        int SetHotkey(ushort wHotkey);\n\n        [PreserveSig]\n        int GetShowCmd([Out] out int piShowCmd);\n\n        [PreserveSig]\n        int SetShowCmd(int iShowCmd);\n\n        [PreserveSig]\n        int GetIconLocation(StringBuilder pszIconPath, int cch, [Out] out int piIcon);\n\n        [PreserveSig]\n        int SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);\n\n        [PreserveSig]\n        int SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, uint dwReserved);\n\n        [PreserveSig]\n        int Resolve(IntPtr hwnd, uint fFlags);\n\n        [PreserveSig]\n        int SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);\n    }\n\n    [Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode), BestFitMapping(false)]\n    public struct WIN32_FIND_DATAW\n    {\n        public uint dwFileAttributes;\n        public FILETIME ftCreationTime;\n        public FILETIME ftLastAccessTime;\n        public FILETIME ftLastWriteTime;\n        public uint nFileSizeHigh;\n        public uint nFileSizeLow;\n        public uint dwReserved0;\n        public uint dwReserved1;\n\n        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]\n        public string cFileName;\n\n        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]\n        public string cAlternateFileName;\n    }\n\n    public static void OpenFolderAndSelectFiles(string folder, params string[] filesToSelect)\n    {\n        IntPtr dir = ILCreateFromPath(folder);\n\n        var filesToSelectIntPtrs = new IntPtr[filesToSelect.Length];\n        for (int i = 0; i &lt; filesToSelect.Length; i++)\n        {\n            filesToSelectIntPtrs[i] = ILCreateFromPath(filesToSelect[i]);\n        }\n\n        SHOpenFolderAndSelectItems(dir, (uint) filesToSelect.Length, filesToSelectIntPtrs, 0);\n        ReleaseComObject(dir);\n        ReleaseComObject(filesToSelectIntPtrs);\n    }\n\n    private static void ReleaseComObject(params object[] comObjs)\n    {\n        foreach (object obj in comObjs)\n        {\n            if (obj != null &amp;&amp; Marshal.IsComObject(obj))\n                Marshal.ReleaseComObject(obj);\n        }\n    }\n}\n</code></pre>\n'}, {'answer_id': 59517153, 'author': 'stax76', 'author_id': 4526366, 'author_profile': 'https://Stackoverflow.com/users/4526366', 'pm_score': 2, 'selected': False, 'text': '<p>There are COM Automation LateBinding IDispatch interfaces, these are easy to use from PowerShell, Visual Basic.NET and C#, some sample code:</p>\n\n<pre><code>$shell = New-Object -ComObject Shell.Application\n\nfunction SelectFiles($filesToSelect)\n{\n    foreach ($fileToSelect in $filesToSelect)\n    {\n        foreach ($window in $shell.Windows())\n        {\n            foreach ($folderItem in $window.Document.Folder.Items())\n            {\n                if ($folderItem.Path -eq $fileToSelect)\n                {\n                    $window.Document.SelectItem($folderItem, 1 + 8)\n                }\n            }\n        }\n    }\n}\n</code></pre>\n\n<p>-</p>\n\n<pre><code>Option Strict Off\n\nImports Microsoft.VisualBasic\n\nPublic Class ExplorerHelp\n    Shared ShellApp As Object = CreateObject("Shell.Application")\n\n    Shared Sub SelectFile(filepath As String)\n        For Each i In ShellApp.Windows\n            For Each i2 In i.Document.Folder.Items()\n                If i2.Path = filepath Then\n                    i.Document.SelectItem(i2, 1 + 8)\n                    Exit Sub\n                End If\n            Next\n        Next\n    End Sub\nEnd Class\n</code></pre>\n\n<p><a href="https://learn.microsoft.com/en-us/windows/win32/shell/shellfolderview-selectitem" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/windows/win32/shell/shellfolderview-selectitem</a></p>\n'}]
['https://Stackoverflow.com/questions/9355', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/234/']