2

I'm using a batch file to automatically launch a software at login. This software maps a remote drives to which one letter is assigned (R:) and opens the file explorer to R:.

I would like to append a line to the batch file that would change the current directory to "This PC" / "Computer", so that --in Windows file explorer-- the user see all available drives including remote ones. I'm aware that it is not a real folder --like the user folder would be for instance-- but a key in the registry.

In the file explorer, is there however a way to access "This PC" in command line/batch file mode?

OuzoPower
  • 347
  • 1
  • 4
  • 11
  • do you mean the you need to use the name of the computer in the batch? Like `%COMPUTERNAME%` – EBGreen Apr 05 '18 at 14:05
  • No, I meant making the Windows file explorer (i.e. the graphical file explorer) point to the "Computer" / "This PC" folder (depending on whether Windows is in version 7, 8 or 10). Anthony Fornito's answer brought the solution to my question. – OuzoPower Apr 06 '18 at 09:37

2 Answers2

6

This works on windows 10, I am not sure if it is version specific.

explorer =

Also:

explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

explorer /root,
Anthony Fornito
  • 9,546
  • 1
  • 34
  • 124
  • Wow! The first tip is magic. So simple and working perfectly. I tested it on Windows 7. The second tip also works on Windows 7, with the same string between curly braces. This slightly alternative syntax also works: `%SystemRoot%\explorer.exe /root,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}` . This string is also present in the registry (run regedit.exe). We find it in Computer\HKEY_CLASSES_ROOT\CLSID\{...} It stores the string "Computer". – OuzoPower Apr 06 '18 at 09:28
0

You can use the WMI Console (wmic.exe) to enumerate the currently available drives.

wmic logicaldisk get deviceid

Results in a list of drive letters:

DeviceID
C:
S:

This won't specifically change the directory, but could provide a list of valid drive names to then navigate to, assuming that is what the intent of the batch file is.

Argyle
  • 63
  • 10
  • Hi! Not exactly what I looking for, as I need Windows file explorer being opened on "This PC". However, thank you for the tip; it is always good to know. – OuzoPower Apr 06 '18 at 09:10