Visual Studio doesn't see all files in System32
Asked Answered
B

1

5

I set some post-build commands in Visual Studio 2017 that should allow me to run a program that I currently have in System32 (wsl.exe). However, Visual Studio doesn't see the program.

I tried to set the command to dir C:\Windows\System32\ to see all the files it could list, and in fact it doesn't list over a 1'000 files out of the around 4'600 files I have there, including the wsl.exe file I'm trying to run. The number of files show up correctly when running the same command in the command prompt.

I've tried to run whoami as the post-build command, and it returns the same user as if I run the same command in the command prompt.

Am I missing something?

Butterflies answered 10/9, 2018 at 8:15 Comment(5)
What does this have to do with Visual Studio? wsl is the Windows Subsystem for Linux. It's not just any executable. You can run it from any folder though, as it's in the path. Just type wsl.Biota
This has to do with Visual Studio because it cannot see the wsl file at all when executing the dir command with it. I know I can run it from any folder, and because it was throwing the error "wsl is not recognized as an internal or external command, operable program or batch file." I've tried more steps and came to the conclusion that running dir in the post-build commands, it didn't show all the files in the directory. All of this while I can see the file correctly using the Windows command promptButterflies
1) no repro. I can see it and call it just fine 2) It has nothing to do with VS. dir is a command-line command. You are asking why you can't see some files in System32, without specifying what those files are. 3) What wsl? Does it even exist? Is it installed? Are you trying to start a Unix shell from your post-build step?Biota
About your number 2): then how come running the dircommand in VS does not show the wsl.exe file, while running ls -al /mnt/c/Windows/System32 in WSL shows it, and in command prompt running `dir C:\Windows\System32` shows it as well. For your number 3): I've clarified that in the post saying that indeed I currently have in System32 (wsl.exe), so yes, it does exist.Butterflies
possible duplicate of Kicking off a WSL bash-based build from Visual Studio 2015Eliathas
S
8

Visual Studio itself is 32-bit application. As such, the OS shims the application behavior to a different view of the Windows and System32 folders. i.e c:\Windows\System32 in the application is actually the c:\Windows\SysWow64 folder for 32-bit apps. That explains why it can't see the wsl.exe binary... Not sure what the workaround is... looking into this...

Slosh answered 10/9, 2018 at 8:20 Comment(7)
wsl is the Windows Subsystem for Linux. It's not missing either, running dir wsl.exe inside System32 works, assuming the feature is installed of course. In any case the OP shouldn't put anything in System32.Biota
Not "putting anything in System32". WSL was automatically installed there using the Programs and Features in the Control Panel. Still, will try, @SloshButterflies
@PeterAS17 you haven't explained what you are trying to do. Or what WSL you refer to. I can start WSL, the Windows Subsystem for Linux, just fine by typing wsl in any console. I can see it just fine with dir after changing the current directory to C:\Windows\System32. I can also see it with dir c:\Windows\system32\wsl.exe.Biota
@PanagiotisKanavos to clarify the output on each side: VS shows "File not found" using the dir c:\Windows\system32\wsl.exe. Command prompt shows the file: 06.09.2018 15:02 114 688 wsl.exeButterflies
@PeterAS17 your real question was how to run a Linux build step. This is already answered in this duplicate questionBiota
@Slosh You're absolutely right... I didn't pay attention to the fact that VS was a 32-bit application and ignored the fact that it pointed to the SysWow64 folder. Copying and pasting the needed files for the post-build command seems to have done the job for now. Gotta search for a better workaround if any. Thanks!Butterflies
File System Redirector: "32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32. WOW64 recognizes Sysnative as a special alias used to indicate that the file system should not redirect the access."Alpheus

© 2022 - 2024 — McMap. All rights reserved.