I am playing around with notifyicon and contextmenustrip and am trying to build a list of all the apps in the start menu and be able to launch them. I am having issues with add_click where I can't get it to write the app I clicked on. I loop through the list of shortcuts and then create a new toolitem object for each one found. All the other attributes I set are saved except for whatever I put in add_click.
Anyone have any ideas?
$applist =Get-ChildItem "c:\documents and settings\all users\start menu\" -recurse
foreach ($app in $applist) {
$ToolItem =$app.name
$ToolItem = New-Object System.Windows.Forms.ToolStripMenuItem
$ToolItem.Size = New-Object System.Drawing.Size(152, 22)
$ToolItem.Text = ($app.name -replace ".lnk","")
ToolItem.add_click({Write-Host $app.name})
$ContextMenuStrip1.Items.AddRange([System.Windows.Forms.ToolStripItem[]](@($ToolItem)))
}
Thanks