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
Related
I open my vscode with code . command from WSL terminal because I want to work directly in my WSL. It works fine and for example, the file explorer of vscode shows directory structures based on WSL machine and not based on my Windows machine.
My problem is however that, when I save a workspace using File -> Save Workspace As, it saves it again as a workspace in my Windows machine. So when I close and open my vscode again and use Open Workspace... to open the already saved workspace(in previous step), explorer reads directories from Windows machine.
You might ask what's the difference between saving files in /mnt/c/Users/[user]/Desktop or C:\Users\[user]\Desktop, but the problem is two things:
I might open a session from a directory in WSL that is (unlike Desktop) inaccessible from Windows.
Even if my Desktop is my current working directory, I may add another directory to my workspace (using Add Folder to Workspace...) and even if it is a path accessible from Windows, the next time I open the workspace, I will get an exclamation mark and such an error near that directory in explorer:
C:\mnt\d\Files_And_Downloads\Google Drive_Code . Can not resolve workspace folder
I suspect this is a bug, vscode has mixed the WSL path and Windows path. So anyone who uses Remote - WSL extension and can tell me what's going on here?
I usually use the shortcut described here: How do I start PowerShell from Windows Explorer? to open a PS session in a specific folder. Just using powershell to open the sessions
However is no longer working, every time I write powershell on the address bar and hit enter it take me to the folder: C:\Users\MyUser\Documents\PowerShell (I'm in a Windows 10 laptop)
It seems to be related only to this shortcut as I have tried a few other things and they work. List of things I have tried/checked already below:
powershell -noprofile it work opening a PS session as expected
No, my $Profile file does not have anything to set the location of the PS Session.
powershell.exe works as expected
powershell_ise works as expected
going to File --> Open Windows Powershell works as expected
Checked my environment variables and nothing strange there either
It seems to be related to the fact that I installed PS core 6 recently. This installation introduced the folder C:\Users\MyUser\Documents\PowerShell (it's a new folder vs the ones that existed with Windows Powershell) and that's why the windows explorer now opens a folder instead of the command line.
I suppose I will need to get used to powershell.exe instead of powershell from now on.
I am using Notepad++ with workspaces, created through "Open Folder as Workspace".
I am trying to launch external command from Notepad++ using the Run command menu.
The variable FULL_CURRENT_PATH give me the current file path but I need to get the worskpace path to launch some deployment script in the root of the workspace.
Is there a variable for workspace path ?
I'm afraid there is no such variable. You can see a list of all variables in the source code of Notpad++:
https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp
You can read the Workspace directories from the configuration file, but the file will only be written if Notepad ++ is closed. Maybe someone has an idea how to trigger that
cmd /c echo. |powershell -Command [xml]$nb = Get-Content $env:appdata\Notepad++\config.xml; Write-Output $nb.NotepadPlus.FileBrowser.root.foldername
I am trying to create a workspace in Visual Studio Code using PowerShell. However, the code . command is not working the way I need it to. I have created a path variable in the following location: AppData\Local\Programs\Microsoft VS Code\bin. However, this only works when code . is the first command I run which opens a huge workspace. When I try to cd into specific folders and then use the code . command I get an error that says the system cannot find the path specified.
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.