4

.reg ファイルから既存のレジストリ キーを編集しようとしています。reg_expand_sz 値であるキーの値を別のものに変更したい (値はファイルパスです)。私はこのようにしてみました:

Windows Registry Editor Version 5.00

["HKEY_CURRENT_USER\Control Panel\Cursors"]
"Arrow"=REG_EXPAND_SZ:"%SystemRoot%\System32\VIRUS\Virus\newArrow.cur"

うまくいきませんでした。代わりに何をすべきですか?

4

4 に答える 4

2

PowerShell の使用

sp 'hkcu:control panel/cursors' arrow `
  '%SystemRoot%/System32/VIRUS/Virus/newArrow.cur'

Set-ItemProperty

于 2013-05-15T03:39:08.897 に答える
1

Windows (7) は値を 16 進数として受け入れているようです。それを理解する最も簡単な方法は、手動で編集してから、regedit アプリケーション内でエクスポートすることです。何をすべきかを示します。

私はそれをしてこれを手に入れました、そしてそれはうまくいきます。

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Control Panel\Cursors]
"Arrow"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
  00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,56,00,\
  49,00,52,00,55,00,53,00,5c,00,56,00,69,00,72,00,75,00,73,00,5c,00,6e,00,65,\
  00,77,00,41,00,72,00,72,00,6f,00,77,00,2e,00,63,00,75,00,72,00,00,00
于 2013-05-15T00:55:27.617 に答える
1

powershell を使用すると、変数の展開を回避するのが難しくなります。私が使用している解決策は、RegistryKey.GetValue Method (String, Object, RegistryValueOptions)を呼び出すことですが、少し冗長ですが、その根拠はhttps://www.sepago.com/blog/2013/08/22/reading-で詳しく説明されています。 and-writing-regexpandsz-data-with-powershell

$Hive = [Microsoft.Win32.Registry]::LocalMachine
$keypath='SYSTEM\CurrentControlSet\Control\Session Manager\SubSystems'
$Key = $Hive.OpenSubKey($keypath, $True)

# prevent expansion
$oldValue = $Key.GetValue($valueName, $False, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)

# update the value
$newValue = $oldValue -replace '(^.*SharedSection=\d+,\d+),(\d+) (.*$)', "`$1,$newHeap `$3"
$Key.SetValue($valueName, $newValue, [Microsoft.Win32.RegistryValueKind]::ExpandString)
于 2016-11-18T21:54:24.670 に答える