[英]is there an universal line to delete/uninstall any application?
是否有一條通用線路可以刪除/卸載控制面板中顯示的任何應用程序? 最好是 PowerShell 但可以是另一種語言。 我有刪除.msi not.EXE 的行。 這部分非常困難,我對.EXE和.MSI之間的區別一無所知,如果有人知道我如何區分它們,那么我至少可以解決.msi
這是我為.msi 設置的代碼
$ComputerName = Read-Host -Prompt 'Input the computer name' # the name of the computer to remove the app from
Get-WmiObject Win32_Product -ComputerName $ComputerName | Select-Object -Property Name | Out-GridView -Title "All apps on destination Computer"
$Name = Read-Host -Prompt 'Input name of the application (has to be exact name)' #name of the application
$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name} #choose the object, this will be the app that we will delete
if ($Application) {
$Application.Uninstall()
"
The removal was successful"
}
else {
$Name + ' is not installed on ' + $ComputerName
}
Start-Sleep -Seconds 10
沒有通用的線路,Get-Package 是一個神命令,但是如果你想遠程使用它變得很難處理,因為它需要被調用(調用時問題太多,擁有管理員帳戶是不夠的,因此它違背了創建此應用程序的目的)。 我正在考慮使用以下組合:
`cmd.exe /c "$($app.meta.Attributes["UninstallString"]) /S"`
和
$Application = Get-WmiObject Win32_Product -ComputerName $ComputerName | Where-Object {$_.Name -eq $Name} #choose the object, this will be the app that we will delete
if ($Application) {
$Application.Uninstall()
但隨后問題就變成了正確保護域中的 Get-package 無法在遠程使用。 而 WmiObject 沒有問題。
我還沒有找到使用管理員帳戶遠程刪除.EXE 應用程序的方法。 (當然是 PowerShell)
我是新手,所以我的術語不像其他人那樣發達,但我想我明白了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.