1

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.

KyleM
  • 4,445
  • 9
  • 46
  • 78

1 Answers1

6

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Ok but what I don't understand is why is redirection necessary? If the system32 folder contains 64 bit applications why does it matter? The OS is 64 bit ... edit: I'm saying why can't the OS run both the 32 and 64 bit? – KyleM Jun 29 '11 at 00:27
  • Because there are tons and tons of programs written by programmers that never heard of a 64-bit operating system before. Mostly because there wasn't one yet when they wrote the code. And those programs try to access files in c:\windows\system32. Those programs would fail. It is an application compatibility feature. – Hans Passant Jun 29 '11 at 00:40