WOW64 - running powershell from within Visual Stud

2019-07-23 06:16发布

问题:

Can someone please explain, simply, why it is necessary to go through so many hoops in order to run PowerShell (as an external command) from visual studio? I know it has to do with the bit differences but don't get why. The context is a 64 bit Windows 7 OS, 32 bit Visual Studio, and 32 bit powershell from the System32 folder if I remember correctly. A 64 bit OS can run both 32/64 applications without problems, so what is the issue here, and why?

By internet searching I believe this has something to do with WOW64, hence the tag, but I'm not really sure. I know the OS emulates the old 32 bit software but I don't see why VS can't run the command to start powershell without going through hoops, such as adding a '...Native...' folder (that acc. to our instructor doesn't actually exist) to the path.

Hope that isn't confusing.

回答1:

Visual Studio is a 32-bit process, there is no 64-bit version. When you ask it to run something from c:\windows\system32, Windows will redirect the request to c:\windows\syswow64. The home of all 32-bit Windows executables.

Using %windir%\sysnative instead is the workaround, that gets redirected to c:\windows\system32.

The file system redirector is described here.