Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
17.7k views
in PowerShell by 37 41 48
What's the simplest way to open file in PowerShell or CMD (Command Prompt)?
I need to run a program or open file explorer to a specific folder or open files directly in PowerShell, how can I do that?

1 Answer

0 like 0 dislike
by 158 184 366
selected by
 
Best answer

How to Open File from PowerShell and Command-Line?

To open a file regardless of its type/extension, you can use one of the below methods:

Method 1

Start "file path"

Example

PS C:\Users\spfarm> start c:\debug.to.txt

Output

Open File from PowerShell

This cmdlet is also working properly in Command Prompt (CMD)

Method 2

ii "file path"

Example

ii C:\debug.to.txt

Output

Open File from CMD

The ii is the abbreviation of Invoke-Item


How to Open File Explorer In PowerShell?

You can easily open a program like a notepad or File explorer using the same above cmdlets start & Invoke-Item as the following:

Method 1

Start explorer

Method 2

ii C:\Windows\System32\notepad.exe

Output

Open program from PowerShell


How to Open a specific folder path in PowerShell?

Again, you can use the same methods to open a specific folder location in PowerShell as the following:

Method 1

Start C:\debug\backup\

Method 2

ii C:\debug\backup\

See Also

If you don’t ask, the answer is always NO!
...