I am looking for a way to open a file in the windows explorer.
The file directory is stored in a QR Code, after decoding, the path gets copied to the clipboard. From there it needs to be opened in the windows explorer because the QR Decoder doesn't automatically recognize the code as a file path.
Is there a way to process a file path in Powershell and open it in the windows explorer?
If you have a recent version of Powershell then you can just do this:
explorer (Get-Clipboard)
You can open a folder in Windows Explorer via PowerShell like this:
[System.Diagnostics.Process]::Start(<FolderPath>)
Or this:
Start-Process -FilePath <FolderPath>
This also works for other items, such as URLs, which will open in your default browser.
Related
Is it possible in VSC to add a URL that opens a directory in Windows Exporer?
For example: "file:///C:/"
This should open Windows Explorer in the C directory.
It doens't work.
Thanks.
I would like to open a file in vscode under WSL (Windows Subsystem Linux) using the vscode:// url.
You can do it with a normal file in the usual filesystem vscode://file/c:/myProject/package.json
It is clearly explained in the documentation
I would like to open a file which is located in WSL, so to have something like this
vscode://file/home/user/myProject/package.json
But It does not work !
It does not work to use the complete path in windows as it does not start the WSL vscode
vscode://file/C:\Users\john\AppData\Local\Packages\TheDebianProject.DebianGNULinux_76v4gqsdeaz4\LocalState\rootfs/home/user/myProject/package.json
You can use the following scheme vscode://file//wsl$/Ubuntu-18.04
In your case it will be vscode://file//wsl$/Ubuntu-18.04/home/user/myProject/package.json
But unfortunately file is opened in a new window.
Please see https://github.com/microsoft/vscode/issues/99691
To open a remote window, don't use file but vscode-remote.
Please try vscode://vscode-remote/wsl+distro+name/path/to/file
Source: Opening VS Code with URLs doesn't work with \wsl$ urls
I am trying to open explorer via powershell to the current working direcoty and file within in the current working directory.
My main goal is to open an explorer window via powershell to the specified search term, but it keeps asking me to find an app that works with this.
explorer search-ms:displayname=Search%20Results%20in%20C:\MyLOcation&crumb=System.Generic.String%3AFLO**&crumb=location:%5C%5CC:\MyLocation
This works in Run and CMD, but not powershell.
So I created a internet shortcut on my computer and I am trying to launch that from powershell and it can't find it unless I hardcode the path. I would rather find the path programmatically.
$cwd = (Get-Item -Path ".\").FullName + "\MyLocation.url"
explorer $($cwd)
Should launch the path to C:\MyLocation
You can use:
ii .
to open the current directory via PowerShell
I am trying to open .html file with the help of powershell. I am using Yeoman and opening it with the command "Grunt Server" but it keeps opening it in default browser. Which command should I use to open it (for example) with Chrome?
I could change my default browser to Chrome but it is just interesting to know.
You should try running start chrome <your_filename_path> from the command line.
Also if you know the Chrome path try opening via (for example):
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" <your_filename_path>
hello pals if you want to open a index.html file by firefox, run on power-shell.
> c:\path/to/firefox.exe index.html
example in my case
> 'c:\Program Files\Mozilla Firefox\firefox.exe' .\index.html
I've got some .py and etc. file with code.
How to open it in powershell as text? I mean using invoke-item allows to open .txt in notepad but code.py will be executed using python.
So how to open it using powershell but in notepad at least(in notepad++ preferably)
Invoke-Item will open the application that has the file association for that file extension.
You could try Start-Process. I assume .py files will behave the same as .cs files but
Invoke-Item a.cs opens visual studio
Start-Process notepad a.cs opens notepad
But then again
notepad a.cs opens notepad as well.
If you're really keen to use Invoke-Item it appears its possible to update file associations using PowerShell - change-file-asociations-via-powershell
As already said just use:
notepad yourcode.py
As for notepad++, perhaps the best ways to do it are stated here:
How to execute a PowerShell script from Notepad++