#=================================================================
# AUTHOR: Kees Baggerman
# COMPANY: Inter Access B.v.
# DATE: 21-02-2010
# Version: 0.2
# Puts all the app-v applications in an drop down menu
# and removes the PKG files from the selected application.
#=================================================================
if (Test-Path HKLM:\SOFTWARE\Microsoft\Softgrid\4.5\Client\Applications)
{
# Get all subkeys from HCKU:\
$HKLM = 2147483650
$key = "SOFTWARE\Microsoft\Softgrid\4.5\Client\Applications"
$reg = [wmiclass]‘\\.\root\default:StdRegprov’
$subkeys = $reg.EnumKey($HKLM, $key)
$subkeys.snames
# Put all of the registry keys in an array and put that in a dropdown menu.
[array]$DropDownArray = $subkeys.snames
# This Function Returns the Selected Value and Closes the Form
function Return-DropDown {
$Choice = $DropDown.SelectedItem.ToString()
$Form.Close()
function Get-RegistryValue($key, $value) {
(Get-ItemProperty $key $value).$value
}
$AppName = Get-RegistryValue HKLM:\SOFTWARE\Microsoft\Softgrid\4.5\Client\Applications\$Choice `
AppPath
$AppName = $AppName.Substring(1,8)
Function FindFolder
{
$input | Where-Object {$_.Name -match $AppName}
}
$AppLoc = Get-ChildItem -Path $Env:AppData | FindFolder
Remove-Item $Env:AppData\$AppLoc -recurse
}
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$Form = New-Object System.Windows.Forms.Form
$Form.StartPosition = "CenterScreen"
$Form.width = 300
$Form.height = 150
$Form.Text = ”AppVPKGRemover”
$DropDown = new-object System.Windows.Forms.ComboBox
$DropDown.Location = new-object System.Drawing.Size(100,10)
$DropDown.Size = new-object System.Drawing.Size(130,30)
ForEach ($Item in $DropDownArray) {
$DropDown.Items.Add($Item)
}
$Form.Controls.Add($DropDown)
$DropDownLabel = new-object System.Windows.Forms.Label
$DropDownLabel.Location = new-object System.Drawing.Size(10,10)
$DropDownLabel.size = new-object System.Drawing.Size(100,20)
$DropDownLabel.Text = "Applications"
$Form.Controls.Add($DropDownLabel)
$Button = new-object System.Windows.Forms.Button
$Button.Location = new-object System.Drawing.Size(100,50)
$Button.Size = new-object System.Drawing.Size(100,20)
$Button.Text = "Remove files"
$Button.Add_Click({Return-DropDown})
$form.Controls.Add($Button)
$Button1 = new-object System.Windows.Forms.Button
$Button1.Location = new-object System.Drawing.Size(100,75)
$Button1.Size = new-object System.Drawing.Size(100,20)
$Button1.Text = "Quit"
$Button1.Add_click({ $form.close() })
$form.Controls.Add($Button1)
$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()
}
else
{
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$Form = New-Object System.Windows.Forms.Form
$Form.StartPosition = "CenterScreen"
$Form.width = 300
$Form.height = 150
$Form.Text = ”AppVPKGRemover”
# Create the label control and set text, size and location
$label = New-Object Windows.Forms.Label
$label.Location = New-Object Drawing.Point 100,50
$label.Size = New-Object System.Drawing.Size(125,20)
$label.text = "App-V is not installed!"
$form.controls.add($label)
$Button1 = new-object System.Windows.Forms.Button
$Button1.Location = new-object System.Drawing.Size(100,75)
$Button1.Size = new-object System.Drawing.Size(100,20)
$Button1.Text = "Quit"
$Button1.Add_click({ $form.close() })
$form.Controls.Add($Button1)
$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()
}
3 comments