Powershell을 사용하여 .reg 파일로 키 내보내기

Powershell을 사용하여 .reg 파일로 키 내보내기

VLC를 실행하는 명령에 매개변수를 추가하려면 Windows 7 레지스트리에서 여러 주요 값을 변경해야 합니다.

다행히 모든 키는 다음으로 시작하는 키의 하위 항목입니다 VLC..

여기에 이미지 설명을 입력하세요

Open및 에 대한 명령을 PlayWithVLC편집해야 합니다. 나는 다음에 대해 생각하고 있습니다 :

  • .reg 파일로 키 내보내기,
  • --no-playlist-enqueue라인에 추가하기 위해 외부에서 값 편집
  • 레지스트리에서 .reg 파일을 다시 가져옵니다.

PowerShell에 대한 내 기술은 제한되어 있으므로 코드는 다음과 같아야 한다고 가정합니다.

Get-ChildItem "Registry::HKCR" -Recurse -Force 
| where { $_.Name -match 'vlc.'}`
| ForEach-Object {
    try {
        <create .reg entry>
    }
    catch { }
}

하지만 나는 이 시점에서 막혔습니다. 앞으로 어떻게 진행해야 할지 조언을 좀 주실 수 있나요?

답변1

좋습니다. PS 기술이 제한되어 있고 레지스트리 조작을 자동화하고 싶습니다.

아아아아... 확실해요? 8-}

말한 모든 것.

여기에 표시된 내용은 설정할 값이나 레지스트리 키를 설정하는 명령을 표시하지 않는다는 점을 제외하면 괜찮습니다.

이러한 cmdlet은 레지스트리를 처리하는 데 사용할 수 있는 cmdlet입니다.

Get-Command -CommandType Cmdlet -Name '*item*'


CommandType     Name                  ModuleName
-----------     ----                  ----------
Cmdlet          Clear-Item            Microsoft.PowerShell.Management
Cmdlet          Clear-ItemProperty    Microsoft.PowerShell.Management
Cmdlet          Copy-Item             Microsoft.PowerShell.Management
Cmdlet          Copy-ItemProperty     Microsoft.PowerShell.Management
Cmdlet          Get-ChildItem         Microsoft.PowerShell.Management
Cmdlet          Get-Item              Microsoft.PowerShell.Management
Cmdlet          Get-ItemProperty      Microsoft.PowerShell.Management
Cmdlet          Move-Item             Microsoft.PowerShell.Management
Cmdlet          Move-ItemProperty     Microsoft.PowerShell.Management
Cmdlet          New-Item              Microsoft.PowerShell.Management
Cmdlet          Remove-Item           Microsoft.PowerShell.Management
Cmdlet          Remove-ItemProperty   Microsoft.PowerShell.Management
Cmdlet          Set-Item              Microsoft.PowerShell.Management
Cmdlet          Set-ItemProperty      Microsoft.PowerShell.Management

마찬가지로 사용하기 전에 도움말 파일과 해당 예제를 살펴보시기 바랍니다.

https://docs.microsoft.com/en-us/powershell/scripting/getting-started/cookbooks/working-with-registry-entries?view=powershell-6

https://blogs.technet.microsoft.com/heyscriptingguy/2015/04/02/update-or-add-registry-key-value-with-powershell

PSRemote레지스트리 1.0.0.0

이 모듈에는 로컬 또는 원격 컴퓨터에서 레지스트리 하위 키 및 값을 생성, 수정 또는 삭제하는 기능이 포함되어 있습니다.

https://www.powershellgallery.com/packages/PSRemoteRegistry/1.0.0.0

https://stackoverflow.com/questions/28076128/powershell-export-multiple-keys-to-one-reg-file

우리가 알고 있듯이, 주의하지 않으면 레지스트리를 조작하는 것이 정말 해로울 수 있습니다. 따라서 재해가 발생하는 경우 복원할 수 있도록 먼저 백업하거나 최소한 시스템 복원 지점인 VM 체크포인트/스냅샷으로 백업하세요.

따라서 게시된 코드를 약간 수정했습니다. 그러나 취해야 할 작업과 방법을 결정해야 하므로 이를 최종적인 것으로 간주하지 마십시오.

Get-ChildItem "Registry::HKCR" -Recurse -Force `
| where { $_.Name -match 'vlc.'}`
| ForEach-Object {
    try {
            'Target key to modify / export / whatever'
            $_.Name
            # 'Registry code here' -WhatIf # remove the whatif if you are sure you are good with what you have
    }
    catch { 
               Write-Warning -Message 'Key not accessible' 
               $_.Name
          }
}

관련 정보