作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果启动Powershell的32位实例(%SystemRoot%\ syswow64 \ WindowsPowerShell \ v1.0 \ powershell.exe),则注册表提供程序仅会看到注册表中有限的32位部分。
**32-bit console**
PS> (dir HKLM:\SOFTWARE | measure).count - (dir HKLM:\SOFTWARE\wow6432node | measure).count
0
**64-bit console**
PS> (dir HKLM:\SOFTWARE | measure).count - (dir HKLM:\SOFTWARE\wow6432node | measure).count
-5
最佳答案
当Powershell以32位进程运行时,我不知道将其“切换”到64位模式的机制。 64位系统中虚拟化支持的全部目的是使32位进程相信它们生活在32位OS中...
但是,这表示我过去使用以下技术,并且对我来说非常有效(以下代码已在带有Powershell v1的Vista SP1 x64上进行了测试)。该技术依赖于这样一个事实:即使从32位进程中调用,.NET的“任何CPU”可执行文件也将作为64位进程运行。我们将执行的步骤:
# file "test.ps1"
$basePath = Split-Path -resolve $myInvocation.MyCommand.Path
$exe = Join-Path $basePath test.exe
&"$env:SystemRoot\Microsoft.NET\Framework\v3.5\csc.exe" /nologo /target:exe /out:$exe (Join-Path $basePath test.cs)
&$exe (Join-Path $basePath visibility.ps1)
// file "test.cs"
using System.Diagnostics;
static class Program {
static int Main(string[] args) {
ProcessStartInfo i = new ProcessStartInfo("powershell", args[0]);
i.UseShellExecute = false;
using(Process p = Process.Start(i)) {
p.WaitForExit();
return p.ExitCode;
}
}
}
# file "visibility.ps1"
(dir HKLM:\SOFTWARE).count - (dir HKLM:\SOFTWARE\wow6432node).count
关于powershell - 如何从32位Powershell实例访问64位注册表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/630382/
我是一名优秀的程序员,十分优秀!