[英]Remove Com+ Application using powershell
我目前正在自动化自定义 Windows 应用程序的安装过程,并尝试删除几个 com+ 应用程序,包括它下面的所有内容。
显然,这可以通过右键单击和删除手动完成,但我需要一些东西来简化这个过程,我可以将 powershell 添加到我的自动化过程中。
我已经尝试了下面的代码,但它似乎只删除了应用程序中的组件。 虽然这有帮助,但我需要在另一个步骤中删除该应用程序。
$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()
$app = $appColl | where {$_.Name -eq "ApplicationName"}
$compColl = $appColl.GetCollection("Components", $app.Key)
$compColl.Populate()
$index = 0
foreach($component in $compColl) {
if ($component.Name -eq "SOMECOMPONENT.NAME") {
$compColl.Remove($index)
$compColl.SaveChanges()
}
$index++
}
我希望能够删除该应用程序并删除下面的所有内容。
$comCatalog = New-Object -ComObject COMAdmin.COMAdminCatalog
$appColl = $comCatalog.GetCollection("Applications")
$appColl.Populate()
for ($i=0; $i -lt $appColl.Count; $i++)
{
if ($appColl.Item($i).Name -eq "YourComponentName"){ $appColl.Remove($i) $appColl.SaveChanges() }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.