Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Usage: regtest [-reg|-write|-read]
- $key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
- $file = 'data.txt'
- if ($args.count -eq 0) {
- Write-Host "Usage: regtest [-reg|-write|-read]"
- exit 1
- }
- if ($args[0] -eq "-reg") {
- Get-ChildItem -Path $key | ForEach-Object {
- Write-Host "App name :" $_.GetValue('DisplayName')
- Write-Host "Uninstall:" $_.GetValue('UninstallString')
- }
- }
- if ($args[0] -eq "-write") {
- Get-ChildItem -Path $key | ForEach-Object {
- "[" + $_.GetValue('DisplayName') + "]"
- "# " + $_.GetValue('DisplayName')
- "Uninstall=" + $_.GetValue('UninstallString')
- ""
- } > $file
- }
- $group = ""
- if ($args[0] -eq "-read") {
- Get-Content $file | ForEach-Object {
- if ($_.trim().length -gt 0) {
- $c = $_[0]
- if ($c -ne "#") {
- if ($c -eq "[") {
- $group = $_.trim("[]")
- } else {
- $keyname, $value = $_.split("=")
- if ($keyname -eq "Uninstall") {
- Write-Host "App name :" $group
- Write-Host "Uninstall:" $value
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment