Hi all,
I was fetching certain registry keys using power-shell in which certain keys has to be deleted for handling "printer bi-directional printing option being grayed out" issue. I was using treeview winform in powershell to display the keys.
$form = New-Object System.Windows.Forms.Form $Form.ClientSize = '342, 502' $Form.FormBorderStyle = 'FixedDialog' $treeView = New-Object System.Windows.Forms.TreeView $treeView.Dock = 'Fill' $treeView.CheckBoxes = $true $N1 = $treeView.Nodes.Add('Version-3') $N2 = $treeView.Nodes.Add('Monitors') $N3 = $treeView.Nodes.Add('Printers') $Directory = "HKLM:\system\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\" $datas = Get-ChildItem -path $Directory | Select -ExpandProperty Name foreach($data in $datas) { $s = $data.Split("\") $node = $N1.Nodes.Add($s[9]) } $Directory1 = "HKLM:\system\CurrentControlSet\Control\Print\Monitors\" $datas1 = Get-ChildItem -path $Directory1 | Select -ExpandProperty Name foreach($data1 in $datas1) { $s = $data1.Split("\") $node = $N2.Nodes.Add($s[6]) } $Directory2 = "HKLM:\system\CurrentControlSet\Control\Print\Printers\" $datas2 = Get-ChildItem -path $Directory2 | Select -ExpandProperty Name foreach($data2 in $datas2) { $s = $data2.Split("\") $node = $N3.Nodes.Add($s[6]) } #> $TV_AfterCheck = { if($_.Node.Checked) { [System.Windows.Forms.MessageBox]::Show( 'Node ' + $_.Node.Text + ' checked') } else { [System.Windows.Forms.MessageBox]::Show( 'Node ' + $_.Node.Text + ' unchecked') } } $treeView.Add_AfterCheck($TV_AfterCheck) $form.Controls.Add($treeView) $form.ShowDialog()
Now I want to delete the keys which are checked using remove-itemproperty and remove accordingly .
That means if a option is selected below version-3, it has to be deleted from path
HKLM:\system\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers\Version-3\
if a option is selected below Monitors it has to be deleted from path
HKLM:\system\CurrentControlSet\Control\Print\Monitors\
Could you guys help me out.