1

NOTE: I am on a 64-bit system.

I am having trouble finding articles regarding my current situation. I using PowerShell to test if a certain path exists:

"C:\Windows\SysWOW64\config\systemprofile\Desktop"

and it returns true even though the Desktop folder does not exist in SysWOW64. I know it is related to the fact that I do have the path:

"C:\Windows\System32\config\systemprofile\Desktop"

but I do not know why. In context, I am automating some stuff in Excel (yes, I know it is unsupported, but with the Desktop folders everything works just fine), and I want to test if both paths exist before trying to continue with automation.

My question is, is it necessary to test both paths? Will Excel automation work if I have the Desktop folder in just one of the paths because they seem to be connected somehow?

I have seen this and this article, and that leads me to believe yes, but as a programmer I am hesitant to couple these things so tightly together in case they change in the future. Is there a more elegant solution?

Community
  • 1
  • 1
Jeff.Clark
  • 599
  • 1
  • 5
  • 27
  • How do you test the path, and is UAC with file and registry virtualization enabled? – Ansgar Wiechers Jun 17 '15 at 21:22
  • I use the Test-Path cmdlet, "Test-Path C:\Windows\SysWOW64\config\systemprofile\Desktop". Also, I am ignorant of , "UAC with file and registry virtualization", so I do not know, but I will look that up now. – Jeff.Clark Jun 17 '15 at 21:32
  • This is likely caused by [SysWOW64 File System Redirection](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx) – Mathias R. Jessen Jun 17 '15 at 21:45
  • 1
    Yes, to the Excel part of the question. Excel automation should work regardless of where the folder lives. SysWOW64 File System Redirection happens automatically in the background. – Jan Chrbolka Jun 18 '15 at 00:21

1 Answers1

2

Assuming:

C:\Windows\SysWOW64\config\systemprofile\Desktop

exists, but:

C:\Windows\System32\config\systemprofile\Desktop

does not.

64bit PowerShell:

Test-Path C:\Windows\SysWOW64\config\systemprofile\Desktop
True

Test-Path C:\Windows\System32\config\systemprofile\Desktop
False

32bit PowerShell:

Test-Path C:\Windows\SysWOW64\config\systemprofile\Desktop
True

Test-Path C:\Windows\System32\config\systemprofile\Desktop
True

The second test in the 32bit PowerShell is redirected from system32 to syswow64. Checks for syswow64 are usually not redirected.

You claim Test-Path C:\Windows\SysWOW64\config\systemprofile\Desktop returns true even though that folder does not exist. Are you sure?

Also what's the bitness of your Excel components, if it is 32bit you only need to concern yourself with the SysWOW64 path.

Peter Hahndorf
  • 10,767
  • 4
  • 42
  • 58
  • Hehe, bitness :) Thank you for connecting the dots for me! Using the method found at http://kb.jetreports.com/article/AA-00722/0/How-to-determine-whether-you-have-32-bit-or-64-bit-Excel.html, I see I am running 32bit excel. – Jeff.Clark Jun 18 '15 at 16:06
  • I have tested out the combinations, and I find your example to be explicitly true, as well as not being able to reproduce my question's example. It returns false in both 32 and 64 bit versions of PowerShell when I try it out. Either way, learning has occurred, and you have answered my question quite well, Thanks again! – Jeff.Clark Jun 18 '15 at 16:59