Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 从64位进程从SYSWOW64获取文件列表_Powershell_System32_Syswow64 - Fatal编程技术网

Powershell 从64位进程从SYSWOW64获取文件列表

Powershell 从64位进程从SYSWOW64获取文件列表,powershell,system32,syswow64,Powershell,System32,Syswow64,我在编写powershell脚本时遇到了一个问题。 我应该将3.dll文件从poweshell 64位进程复制到C:\Windows\SYSWOW64文件夹。 如果我使用环境变量 $systemFolder = [System.Environment]::SystemDirectory 所以,在64位系统上的64位进程下 $systemFolder = "C:\Windows\system32" 是用于访问SYSWOW64文件夹的任何环境变量或某种构造。我提出了这样的解决

我在编写powershell脚本时遇到了一个问题。 我应该将3.dll文件从poweshell 64位进程复制到C:\Windows\SYSWOW64文件夹。 如果我使用环境变量

$systemFolder = [System.Environment]::SystemDirectory
所以,在64位系统上的64位进程下

$systemFolder = "C:\Windows\system32"
是用于访问SYSWOW64文件夹的任何环境变量或某种构造。我提出了这样的解决方案,但我认为还有更正确的解决方案

$targetFolder = [System.Environment]::SystemDirectory
if([Environment]::Is64BitProcess){
$targetFolder = "$env:windir\SYSWOW64"
}

非常感谢

我认为该解决方案没有问题,但您的另一个选择可能是在32位进程中运行脚本,您可以使用和RunAs32参数作为作业运行脚本

Start-Job -ScriptBlock {[Environment]::Is64BitProcess} -RunAs32 | Wait-Job | Receive-Job
False

Start-Job -ScriptBlock {[Environment]::Is64BitProcess} | Wait-Job | Receive-Job
True
另一个选择是使用

[Environment]::GetFolderPath([System.Environment+SpecialFolder]::SystemX86)
C:\WINDOWS\SysWOW64