Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open 'This PC' using CMD or Powershell?

I need a way of opening the explorer at This PC , in the same way as opening in a windows explorer Gui, but I am incapable of this as using Explorer.exe in CMD opens quick access.

I tried opening it with a shortcut and that too failed.

Does anyone know of a way to do this?

Cheers

like image 964
EB farnum Avatar asked Jan 15 '20 21:01

EB farnum


People also ask

How do I open my computer in PowerShell?

From the Start Menu Click Start, type ISE, and then click Windows PowerShell ISE. From the Start menu, click Start, click All Programs, click Accessories, click the Windows PowerShell folder, and then click Windows PowerShell ISE.

How do I open my computer with cmd?

The quickest way to access the Run command window is to use this keyboard shortcut: Windows + R. Simply hold down the Windows key and press R on your keyboard.

Can you open cmd from PowerShell?

The command to open Command Prompt from Windows PowerShell is exactly the same as the command to open Command Prompt from Command Prompt. In Windows PowerShell, just type start cmd.exe and press Enter.

Can I use cmd commands in PowerShell?

Many legacy Command Prompt (CMD) commands work in the Windows PowerShell scripting environment. The PowerShell environment carries these commands forward from the most used commands like ping to the most informational commands like tracert from the legacy environment using aliases.


Video Answer


2 Answers

Just like you can run explorer.exe C:\ to open up the C: (or any other drive or folder path), you can also use a file: URI to open paths in Explorer as well. If you just specify the file: protocol without a directory (or specify file:\\), it will open This PC:

explorer file:
explorer file:\\

Note that you can also change the default Explorer location from Quick Access to This PC as well from Folder Options:

Folder Options

You can set this in the registry too if you're after automation to configure this. See my answer on how you can use PowerShell to set the default launch folder in the registry.

like image 147
Bender the Greatest Avatar answered Oct 19 '22 03:10

Bender the Greatest


My experience is that, the following should work:

From cmd:

Start "" "%SystemRoot%\explorer.exe" /Select,"This PC"

From powershell:

Start "$Env:SystemRoot\explorer.exe" "/Select,'This PC'"
like image 3
Compo Avatar answered Oct 19 '22 04:10

Compo