Powershell REG LOAD 命令不起作用 [英] Powershell REG LOAD command not working

查看:39
本文介绍了Powershell REG LOAD 命令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows 7,在 Powershell(以管理员身份运行)中,在离线用户上运行以下命令:

Windows 7, in Powershell (running as admin), running the following command on an offline user:

& REG LOAD HKLM\CHANGEUSER c:\users\testuser\ntuser.dat
Write-Host Loaded with result $?

结果:错误.使用 regedit 检查密钥时,它尚未加载.注意:HKLM\Changeuser 不是预先创建的.

Result: False. On inspection of the key using regedit, it has NOT been loaded. Note: HKLM\Changeuser is not precreated.

如果我从命令提示符(以管理员身份)使用相同的命令,那就没问题了:

If I use the same command from a command prompt (as admin), it is all fine:

REG LOAD HKLM\CHANGEUSER c:\users\testuser\ntuser.dat

结果:命令成功完成,文件已加载到注册表中.

Result: The command completed successfully, and the file has been loaded into the registry.

为什么在使用 powershell 时没有加载到注册表中?我曾尝试使用和不使用调用运算符 (&),但得到相同的结果.

Why is it not loading into the registry when using powershell? I have attempted with and without the call operator (&), but get the same result.

推荐答案

我不会将 hive 附加到 HKLM.您应该将其附加到 HKEY_USERS (HKU).这就是它的用途.

I would not attach the hive to HKLM. You're supposed to attach it to HKEY_USERS (HKU). That's what it's for.

试试:

reg.exe load HKU\Changeuser c:\users\testuser\ntuser.dat
Write-Host Loaded with result $?

您可以像这样访问它:

Set-Location Registry::\HKEY_USERS\Changeuser

如果您想要一个 PowerShell 驱动器(HKEY_USERS 通常没有),您可以使用:

If you want a PowerShell drive (HKEY_USERS normally doesn't have one) you can use:

New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS; 
Set-Location HKU:

<小时>

为了扩展,我已经使用 at.exe 作为服务帐户和本地 SYSTEM 帐户运行的 Task Scheduler 进行了安排,但除了成功之外我一无所获.我什至尝试过 HKLM,并取得了成功.我不清楚你在做什么,但我没有足够的信息来说明它失败的原因.


To expand, I've scheduled this with Task Scheduler running as a service account and as the local SYSTEM account using at.exe and I got nothing but success. I even tried HKLM, and had success. It's not clear to me what you're doing, but I don't have enough information anymore for why it's failing.

这篇关于Powershell REG LOAD 命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆