0

I need to change several key values in Windows 7 registry, to add a parameter to a command launching VLC.

Fortunately all keys are children of keys starting with VLC.:

enter image description here

The command for Open and PlayWithVLC must be edited. I'm thinking about:

  • exporting keys in a .reg file,
  • editing values externally to add --no-playlist-enqueue to the line
  • re-importing the .reg file in the registry.

My skills in PowerShell are limited, I assume the code should be something like this:

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

but I'm stuck at this point. Could you give me some piece of advice on how to proceed further?

1
  • The image you've linked is not working. Could you please update it? Commented Aug 8, 2018 at 0:18

1 Answer 1

1

OK, limited PS skills and you want to automate messing with the registry.

Uhhhhh… are you sure? 8-}

All that being said.

What you show here is fine with the exception of that you don't show the values to be set nor the command to set the registry key.

These cmdlets are the ones you can use to deal with the registry.

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

Be sure to look at the help files and their examples before use as these also.

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

PSRemoteRegistry 1.0.0.0

This module contains functions to create, modify or delete registry subkeys and values on local or remote computers.

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

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

As we know messing with the registry can really hurt if you are not careful. So, back it up first so you can restore if disaster happens or at least to a system restore point, VM checkpoint/snapshot.

So, here's slight modification to your posted code, but don't take this as final as you need to make decisions on what actions need to be taken and how.

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
          }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .