Opening .html file with powershell using non-default browser - 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

Related

How do you fix "google-chrome" is not recognized in VS Code?

I'm trying to run HTML for the first time in VS code, but when I run it, it says
"google-chrome" is not recognized as an internal or external
command,operable program or batch file.
A screenshot of my problem has been attached below.
How can this be fixed?
You have to save that file with the name that browser can recognize, it should look something like 'filename.html'. Then you can open it with a web server application like xampp, or just open it on your file explorer.
The issue is that google-chrome is not a recognized command in Windows (it is in Linux distros).
The easiest way to make it work is saving the ".html" file with a proper name (something.html) and then use the command cd "C:\Users\LGU BATO\Desktop\html\" && something.html.
An explanation of this command is:
First, it will cd into the directory, as listed on the screenshot. This changes the directory of the command prompt window.
It will then open the file with your default browser.

How to open a file in vscode under wsl using the vscode:// url?

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

How to set Windows Terminal (UWP) as an external terminal for Visual Studio Code?

The title mostly says it all about the question.
I want to set the newest Microsoft's Windows Terminal as an external terminal in Visual Studio Code.
I found the WT's executable in C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.4.2382.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe. Then I entered the path into VSC in the terminal.external.windowsExec. Then tried to run my program, but VSC showed a pop-up which says "Could not find "C:\Program". Check whether the path is written right an try again."
Also I have tried to use a shortcut (literally dragged the WT tile from Start to my desktop folder), then entered its path into the setting, but it just opens the app without starting the program.
You are essentially asking VS Code to Run... a program via the Ctrl + Shift + C command.
Per the tip here, you can achieve what you are looking for by simply entering:
wt
...into the terminal.external.windowsExec section.
It might not be handling the space in the filename correctly. Try surrounding the pathname in quotes like this: "C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.4.2382.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe"
WT now supports the "-d" parameter to open itself in a given directory: https://github.com/microsoft/terminal/pull/4023
But VSCODE does not allow to pass arguments to an external terminal: https://github.com/microsoft/vscode/issues/58086
The workaround for this is to create a batch script somewhere called wt.bat containing:
#start wt.exe -d "."
#exit
And put it on vscode Terminal>External: Windows Exec setting.
Note that the "Windows Terminal", as external terminal, does not launch in the workspace directory (issue 90734)
Set terminal.external.windowsExec to wt
Run "Open New External Terminal" from the command palette
A new instance of Windows Terminal opens, but with the default directory, instead of ${workspaceFolder}.
So while the Windows Terminal Preview v0.9 Release allows a starting directory to be specified with -d <starting dir>, it would not work with VSCode up to 1.44 (March 2020).
This should be fixed with VSCode 1.45 (April 2020): PR 90773.
I can open it with this configuration
"terminal.external.windowsExec": "wt.exe"
My windows terminal version is 1.11.2921.0
Then I found that Windows terminal is actually wt.exe
It's in a path like this C:\Program Files\WindowsApps\************\wt.exe
Then, I add the above 'wt.exe' to the vscode configuration file

Use file path from clipboard to open directory in explorer

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.

Windows 10 : Chrome headless not doing anything

When entering the following command in Windows 10 and start a headless chrome version, nothing is happening (with/without extensions):
"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--disable-extensions --headless --disable-gpu --print-to-pdf
It just returns to the command line silently and I can't find any pdf file.
Does anybody had the same issue and manage to solve it ?
I'm using : Google Chrome 63.0.3239.84 (Official Build) (64-bit) (cohort: 63_win_84)
It looks like Chrome doesn't have rights to write in the directory.
Try to launch command with --enable-logging flag. Like:
"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--enable-logging --disable-extensions --headless --disable-gpu --print-to-pdf
You will receive an error. Fix it and it will start to work.
You can find more information here:
How do I use Headless Chrome in Chrome 60 on Windows 10?
I was experiencing this problem.
My solution was to go and download the Canary Build for Chrome.
https://www.google.com/chrome/browser/canary.html
This will then get installed to C:\User\userName\AppData\Local\Google\Chrome SxS\Application. Try running your commands pointing to this install.
chrome needs full path also.
To use it in cmd.exe:
start chrome --enable-logging --headless --disable-gpu --print-to-pdf=%cd%\output.pdf https://www.google.com/