Need to restart wsl everytime after Windows start before using vscode-remote - windows-subsystem-for-linux

I'm running Windows 10 with WSL2. I'm using VSCode with the Remote - WSL extension to open the files from my wsl file system.
When I boot my Windows laptop, and open VSCode I get the following error:
When I perform a wsl.exe --shutdown in PowerShell, and restart Docker Desktop, Everything works fine. But I have to do this after every laptop restart.
Remote WSL extension version: v0.51.4
Visual Studio Code version: v1.51.1
Windows version: 10.0.19041 Build 19041
Someone any idea?

I have had this problem several times, and I have found that on Windows 10 20H2 one of the two options described below solves the problem.
Network reset
This option can make you lose your network configuration, so use it with discretion and read every warning. You can perform this task by going to Settings > Network & Internet > Status. There you need to click on the option "Network reset" after that, you can start the network reset by clicking on "Reset now" Picture of Windows 10 20H2 status section. Then you will need to wait some minutes until your PC is restarted automatically and try to execute Visual Studio Code under WSL2 again.
Reset Windows
This option is dangerous as it will remove either all your files and programs or all your installed programs. You select what you want to remove before starting the reset process. This option can be performed by going to Settings > Update & Security > Recovery. Then you have to click on the button "Get started" on the section "Reset this PC" and follow the instructions provided by the reset tool Picture of Windows 10 20H2 recovery section. After your Windows is reset, you will have to configure your WSL again because all your WSL files will be lost when executing this operation.

Related

VirtualBox won't run win10: Failed to open a session for the virtual machine w10. Result Code: NS_ERROR_FAILURE (0x80004005)

Ok so I want to get a virtual machine with Windows so I can download applications only on Windows (Not on OSX (I'm on Big Sur 11.2.3 by the way)), so I downloaded VirtualBox, then downloaded the Windows thing which apparently I have to (as seen in one of the pics) (you can tell I have hardly any experience with vms), then I created a new vm in the VirtualBox app, and left all the default settings except for the type of hard drive (which is also in one of the pictures), then I clicked Start and it asked me to add a 'virtual optical disk file', so I clicked on the folder button then clicked add in the top left, and it gave me this error code:
Failed to open a session for the virtual machine w10.
The VM session was aborted.
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: SessionMachine
Interface: ISession {c0447716-ff5a-4795-b57a-ecd5fffa18a4}
as you can also see in one of the pictures below. Also, when I leave the screen for a couple of minutes right before I click on the previously mentioned add button, this appears:
but I tried just leaving it to load, and nothing happened. I have tried uninstalling using the uninstall tool twice, rebooting my Mac, etc etc, and yes I have allowed everything I need to in the Security settings. I'm not installing it on a moderator account, but the Windows 10 virtual optical disk file is in Documents which the account I'm on has read and write access to, and obviously the actual VM is in applications.
Thanks so much!
Here's the previously mentioned image of the one changed setting:
And here's the pic of the Win10 64-bit I had to install:
thanks everyone!
VirtualBox Version: 6.1.22 r144080 (Qt5.6.3)
Host Operating System: MacOS BigSur
I came across exactly same issue, where clicking on add to choose image was crashing the dialog. This issue persists in the latest version of Virtual Box for Mac.
I could figure out couple of ways to avoid clicking on Add button to choose image.
First Option:
Steps:
Click on Settings to open settings window for your VM.
Choose Storage
Select Empty disc and choose Disk image by clicking small disc icon in the Attributes section. Please follow the image to have visual instructions.
Second Option:
Steps:
Click on VM's Normal start
Once you get the option to choose image, simply cancel the dialog.
Now click on the small disc icon in the bottom of VM's dialog to choose the image.
Hope this helps. Feel free to comment if you find this post useful.
I had the same message because of permissions at directories where the hard disks were stored in. So, just execute VirtualBox 'As Administrator' and all run well.
I was getting the same error on Ubuntu 22.04 machine while trying to start an existing or a new VM-
Failed to open a session for the virtual machine NuacareRocky.
The VM session was aborted.
Result Code: NS_ERROR_FAILURE (0x80004005)
Component: SessionMachine
Interface: ISession {c0447716-ff5a-4795-b57a-ecd5fffa18a4}
I tried a few things as suggested on youtube, but nothing worked. finally, I just upgraded the extension and it worked.

(WSL error at Startup) Press any key to continue

Problem:
When I launched Ubuntu 20.04, it pops up: "Press any key to continue...", and then if I press any key, it exits immediately. This prevents me from using (typing any command) in Ubuntu WSL. (It occurred suddenly today. For the last couple of days it has been working properly.)
Screenshot: Press any key to continue pops up after startup
Attempts Tried:
LxssManager service is running. But LxssManagerUser and LxssManagerUser_60d78 are stopped. Manually starting the two services doesn't help as they automatically stop themselves right afterwards.
Hyper-V service is set to auto. Virtualization mode is enabled (task manager -> performance -> CPU)
Trying to re-run the update from here https://learn.microsoft.com/en-us/windows/wsl/wsl2-kernel, but it shows WSL not installed (which is weird since I have been using it for a long time before)
Environment:
OS: Microsoft Windows 10 Family, Insider Preview
Version: 10.0.20152 Version 20152
System Type: x64 based
I'd accidentally mounted the WSL virtual disk image by double-clicking it in explorer, and it remained mounted to my machine even though it reported an error that made having it mounted useless. Unmounting the vdisk from Disk Management resolved the issue for me.
From https://github.com/microsoft/WSL/issues/4177#issuecomment-597736482
There is a conflict between wsl.exe and Proxifier.
Developers of Proxifier gave a solution.
Thanks for the info.
We have reproduced this issue. Apparently, wsl.exe displays this error
if Winsock LSP DLL gets loaded into its process.
The easiest solution is to use WSCSetApplicationCategory WinAPI call
for wsl.exe to prevent this. Under the hood the call creates an entry
for wsl.exe at
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog
This tells Windows not to load LSP DLLs into wsl.exe process.
We have a tool that can make this call:
www.proxifier.com/tmp/Test20200228/NoLsp.exe
Please just run as admin with the full path to wsl.exe as the
parameter: NoLsp.exe c:\windows\system32\wsl.exe
This has fixed the problem in my case.
Please let me know how it works for you.
And it works well for me!
This worked magic! Go to the Windows Command Prompt and run the following command:
netsh winsock reset
Then Restart your computer. NB: Don't Shutdown since it did not work for me. Instead, Restart!
More answers can be found here.
I solved by downloading the https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msimsi and excuting it.
see https://learn.microsoft.com/en-us/windows/wsl/wsl2-kernel
I went into the bios and had to enable virtualization from there
if you got this error:
An operation was attempted on something that is not a socket.
there is something wrong with windows sockets and try this command in cmd administrator mode to reset windows sockets.
1. netsh winsock reset catalog
2. netsh int ipv4 reset reset.log
3. netsh int ipv6 reset reset.log
4. Restart the computer.
Maybe not relevant for TO but I had the same issue and just had to run in Windows Terminal:
wsl --shutdown
After that Ubuntu worked again.
powershell => type "wsl --shutdown" => error message
ctrl-alt-del => services => HvHost => right button => restart (think to stop all hyperv virtual machines before ?)
powershell => type "wsl" => OK
restart hyperv virtual machines

Cannot start windows phone emulator in visual studio 2015

My machine is HP EliteBook 8540w which supports Hyper-V as far as I know and I have enabled it in BIOS. However, I am receiving the following error when trying to start emulator for Windows Phone apps in Visual Studio 2015:
Windows Phone Emulator is unable to start because the hypervisor is not running.
The more detailed screen shot follows:
According to my i7-720QmCPU specs, it supports VT-d
So what is the reason for it being unable to start the emulator on my machine?
Update:
I also checked using the BIOS settings using coreinfo tool with the results as in the following picture:
Update:
Following stijnvangaal's comment, I ran the following command as administrator and rebooted.
'bcdedit /set hypervisorlaunchtype auto'
But, in the wake of next run I faced the following Window ("Virtual machine service not running")
Then, I started this (by clicking the link on the message box):
Under, action menu, I clicked "start service" and then ran the application again in visual studio. Success? Not yet unfortunately, ending up in this (feeling desperate):
I had the same issue :
1 - I disable the Hyper V mode in the Windows Feature :
Go to ‘Programs and Features’.
Select Turn Windows Features on or off.
Deselect Hyper-V and click OK.
2 - Restart the computer
3 - Enable Hyper V again in the Windows Feature.
And it works !
Hope it help :)
Just disable Hyper-V on "Programs and Features" (if it is enabled). Then restart computer and turn it on again. Problem solved for me

Can I have remote ssh terminal access in PhpStorm?

I develop locally using PhpStorm, Git and VirtualBox on my local machine. I use Git to handle the process of moving work to staging or production environments. Currently I'm using MobaXterm (an excellent free tabbed ssh client for windows) to have terminal access to do things on staging and production servers. PhpStorm has a local terminal built in, but how would I use it to have multiple ssh terminal access? (This way I can have local, remote staging, and remote production terminal access all from within my IDE)
Figured it out!
On a fresh copy, PhpStorm will have Tools > Terminal to bring up the local terminal. To have additional ssh terminal access, this is what I did...
Setup servers
1.1) File > Settings > (Type: "Deployment" into the search box)
1.2) Hit the + button and fill in the necessary fields into the connection tab.
1.3) Click on the "Mappings" tab and clear the field "Local path"
since we will only be using the terminal.
1.4) Repeat Steps 1.2 and 1.3 for each server you want a terminal tab for.
1.5) Don't set any of these as default, so that you will be prompted to choose
a server in Step #2 below...
Start a remote terminal tab (this will also open up local terminal)
2.1) Tools > Start SSH session (this option doesn't appear until Step #1 is
completed)
2.2) You will be prompted to select a server from Step #1.
The terminal window appears and a new tab appears next to "local" in the
terminal window.
EDIT: (Thanks to Dan Dascalescu) you may want to also ensure the SSH Remote Run plugin is enabled. It's enabled by default in PhpStorm 8 (not sure about earlier versions).
PhpStorm has a plugin called "SSH Remote Run".
See also the built-in terminal.

How to run a command in cmd on startup in Windows XP

Sigh. For reasons, I am running a windows xp virtual box in ubuntu. In this instance of windows there is an express (node) server running. Everything works fine, except that occasionally windows crashes or the virtual box freezes (perhaps after being left idle for several days). I would like to restart the virtual box (and node server) programmatically when this happens. The actual restarting of the virtual box from linux seems attainable, but I can't figure out how to get windows to run "node .../server.js" on startup! I tried putting the command in C:\AUTOEXEC.bat, and it did not start when I restarted the computer. I know I'm asking for trouble with a 10 year old OS but it's what I have to work with. Any thoughts?
Try scheduling in as a task in the task scheduler.
Tasks get executed when their triggers are satisfied, and in this case you can use the 'at startup' trigger, as described here:
http://technet.microsoft.com/en-us/library/cc748841.aspx
At startup
This trigger causes the task to run when the computer starts up. The only settings for this trigger are the advanced settings described in the Advanced Settings section below.
Look out though, that information wasn't tailor-made for XP, but should do it for you.
I actually just got it working. I put a batch file in start/programs/startup that CD'd to the right directory and then ran node.