测试路径问题
Test-Path issue
为什么Test-Path -Path $folder -PathType Container
return true
,但是文件夹不存在?
路径是:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MyCompany\Modules
ISE x86 和 ISE 中的代码相同,但结果不同
答案是here
摘录:
The 'System32' folder is for 64-bit files and the 'SysWOW64' folder is for 32-bit files
This can be somewhat confusing, but the System32 folder is intended
for 64-bit files and the SysWOW64 folder is intended for 32-bit files.
This may seem a bit illogical if you look at the folder names, but
there is an explanation to this. It has to do with compatibility. Many
developers have hard coded the path to the system folder in their
applications source code. They have included "System32" in the folder
path. And to preserve compatibility, if the application is converted
to 64-bit code, the 64-bit system folder is still named System32.
But what about 32-bit applications that have the system path hard
coded and is running in a 64-bit Windows? How can they find the new
SysWOW64 folder without changes in the program code, you might think.
The answer is that the emulator redirects calls to System32 folder to
the SysWOW64 folder transparently so even if the folder is hard coded
to the System32 folder (like C:\Windows\System32), the emulator will
make sure that the SysWOW64 folder is used instead. So same source
code, that contains a path with the System32 folder included, can be
compiled to both 32-bit and 64-bit program code without any changes.
So remember: • the SysWOW64 folder is intended for 32-bit files only
• the System32 folder is intended for 64-bit files only It is very
important that a binary file compiled to a specific bitness (32 or 64)
is installed to the correct system folder. Otherwise the program that
needs the file will not be able to load the file and will probably not
work as expected.
这就是为什么 ISE x86 输出在 SysWow64 文件夹中并且调用:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MyCompany\Modules
被重定向到 SysWow64 文件夹。
ISE 控制台 运行 作为 x64,因此将在 System 32 中查找并且找不到此文件夹,但该文件夹是在 ISE x86 控制台中创建的,它将文件夹保存在 SysWOW64 下。
为什么Test-Path -Path $folder -PathType Container
return true
,但是文件夹不存在?
路径是:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MyCompany\Modules
ISE x86 和 ISE 中的代码相同,但结果不同
答案是here
摘录:
The 'System32' folder is for 64-bit files and the 'SysWOW64' folder is for 32-bit files
This can be somewhat confusing, but the System32 folder is intended for 64-bit files and the SysWOW64 folder is intended for 32-bit files.
This may seem a bit illogical if you look at the folder names, but there is an explanation to this. It has to do with compatibility. Many developers have hard coded the path to the system folder in their applications source code. They have included "System32" in the folder path. And to preserve compatibility, if the application is converted to 64-bit code, the 64-bit system folder is still named System32.
But what about 32-bit applications that have the system path hard coded and is running in a 64-bit Windows? How can they find the new SysWOW64 folder without changes in the program code, you might think.
The answer is that the emulator redirects calls to System32 folder to the SysWOW64 folder transparently so even if the folder is hard coded to the System32 folder (like C:\Windows\System32), the emulator will make sure that the SysWOW64 folder is used instead. So same source code, that contains a path with the System32 folder included, can be compiled to both 32-bit and 64-bit program code without any changes.
So remember: • the SysWOW64 folder is intended for 32-bit files only • the System32 folder is intended for 64-bit files only It is very important that a binary file compiled to a specific bitness (32 or 64) is installed to the correct system folder. Otherwise the program that needs the file will not be able to load the file and will probably not work as expected.
这就是为什么 ISE x86 输出在 SysWow64 文件夹中并且调用:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\MyCompany\Modules
被重定向到 SysWow64 文件夹。
ISE 控制台 运行 作为 x64,因此将在 System 32 中查找并且找不到此文件夹,但该文件夹是在 ISE x86 控制台中创建的,它将文件夹保存在 SysWOW64 下。