yuk7 / ArchWSL

ArchLinux based WSL Distribution. Supports multiple install.
https://git.io/archwsl
MIT License
6.92k stars 201 forks source link

How to unregister files from WSL? #66

Closed ohmree closed 5 years ago

ohmree commented 5 years ago

Describe the issue I deleted the files created by Arch.exe from explorer (should've ran Arch.exe clean, I know) and now some of them can't be deleted from explorer or powershell (the directory name is invalid). I assume I need to unregister them from the WSL somehow

To Reproduce

  1. Run arch.exe to install Arch
  2. Ctrl-A Shift-Del (delete everything from explorer)

Expected behavior Proper deletion

Enviroment:

Additional context Not sure if this is the right section for this question, but is there a way to view all registered WSL distros? Even if you have to directly use the Win32 API, I'd appreciate it if you refer me to the docs for the parts of the API that are required to do this.
Also if you require any other info I'll supply it.

hdk5 commented 5 years ago

Try

wslconfig.exe /unregister arch

See more at https://docs.microsoft.com/en-us/windows/wsl/wsl-config

ohmree commented 5 years ago

It prints There is no distribution with the supplied name.. Also wslconfig /list /all shows that there aren't any distros installed.

hdk5 commented 5 years ago

That's strange. Can you create WSL instance with the same name as you had first or with some other name?

ohmree commented 5 years ago

With the same name you had first

I'm not sure what that would be, I just ran arch.exe. Also, sorry for my ignorance but what do you mean by "create a WSL instance..."? How does one create a WSL instance?

hdk5 commented 5 years ago

By "WSL instance" I mean registered distribution.

Are you getting any errors when running arch.exe after manually removing your distribution files? (i.e. without running arch.exe clean)

wsldl installs distributions with the same name as its .exe, so in case you can't run arch.exe, I suggest you to rename the executable, run it, and using this new distro try to remove files that remain from previous linux subsystem.

ohmree commented 5 years ago
./arch

and

mv arch.exe test.exe
./test

The output for both is:

Installing...
ERROR:Installation Failed!
HRESULT:0x800700b7
Press any key to continue...

Also if it helps, I just noticed I can rename the directories either through explorer or using Powershell's rename-item

Lastly, my directory structure is as follows:


    Directory: C:\Users\USER\Desktop\Arch

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       10/19/2018   2:36 PM                arch2
da----       12/11/2018   1:43 PM                rootfs
d-----       10/19/2018   3:26 PM                temp
-a----        10/3/2018   2:21 AM         550285 Arch.exe
-a----        10/8/2018   2:52 PM      191052309 rootfs.tar.gz

    Directory: C:\Users\USER\Desktop\Arch\arch2

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
da----       10/19/2018   3:23 PM                rootfs
d-----       10/19/2018   3:23 PM                temp
-a----        10/3/2018   2:21 AM         550285 Arch.exe
-a----        10/8/2018   2:52 PM      191052309 rootfs.tar.gz

    Directory: C:\Users\USER\Desktop\Arch\rootfs

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
da----       10/19/2018   2:34 PM                usr
da----       10/19/2018   1:43 PM                var

Inside arch2 there's another installation of ArchWSL, can't remember why I installed another one.

hdk5 commented 5 years ago

Have you also tried to restart LxssManager service, as this comment suggests?

ohmree commented 5 years ago
$ sc.exe query LxssManager

SERVICE_NAME: LxssManager
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 1077  (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Should I try to start and then stop it again?

Also the comment you linked to mentions this command: dism /Online /Cleanup-Image /RestoreHealth Doesn't this reset the system? I had an incident on another computer where I accidentally deleted some system files and read that this can help, but then when I asked on a tech support IRC channel I was told that this is like a factory reset. I don't think this part of the comment is relevant to my problem but just wanted to make sure, since that experience was very harrowing

hdk5 commented 5 years ago

Should I try to start and then stop it again?

LxssManager service should be running.

Doesn't this reset the system?

I don't think you need this, but no, it does not.

ohmree commented 5 years ago

Ok, this is kind of funny. I enabled LxssManager which allowed me to delete most of the files/folders, with a few exceptions:

According to this:

The issue is that CON is a reserved name in Windows, so it doesn't like folders with this name. (Similar things likely happen with other reserved names like PRN.) The problem arises when you have this folder created by other operating systems where it isn't a reserved word. You can remove this using the command line, but will want to reference the location differently than you normally would (using UNC). If the folder is C:\documents\con, then this command entered on the command line will remove it: rd \\.\c:\documents\con /S /Q

So I ran rmdir /s \\.\C:\Users\Username\Desktop\Arch in an admin prompt (maybe I could've used a normal prompt, didn't try) and was left with the empty Arch folder. When I tried to delete it from explorer it said it was being used by a process but after a few minutes I tried to rmdir it from the command prompt and now it's gone

Thank you @hdk5 pointing me in the right direction, and I hope that if this happens to other users they'll find my solution helpful.

johnjohnk2 commented 3 years ago

Hi @hdk5 @ohmree , I have a similar problem cleaning a mis installed arch WSL. Now at every startup I have two instances of HyperV. I can delete the first one without any problem but I can't delete the second one ( if so i loose connection on my current archWSL windows terminal ) Don't know how to clean definitely this old install. Thanks for your help

unknown