Translate

Remote Uninstall

Ova skripta služi da se ukloni bilo koji program sa udaljenog računara, naravno ukoliko imate administratorska prava. Ja sve moje skripte potpisujem sertifikatom (deo kog ovde nema).


##################################################################  
####                                                            
####                 REMOTE UNINSTALL            
####                                                            
####             Written by Nikola Batinica      
####               Date: 15/01/12         
####                             
####  
##################################################################  
function listprograms {  
  
Get-WmiObject win32_product -ComputerName $address.Text | Out-GridView  
  
}  
  
function remoteuninstall {  
  
$app = Get-WmiObject win32_product -ComputerName $address.Text | Where-Object {$_.name -match $program.Text}  
$returnvalue = $app.uninstall() | Select-Object -Property returnvalue  
if($returnvalue.returnvalue -eq "0")  
{[Windows.Forms.MessageBox]::Show("Uspešno uklonjen program!")}  
else{[Windows.Forms.MessageBox]::Show("Program nije uklonjen!")}  
}  
  
  
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")  
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")  
  
$Form = New-Object System.Windows.Forms.Form  
  
$Form.width = 500  
$Form.height = 300  
$Form.Text = "Udaljeno uklanjanje programa"  
$Form.backcolor = "#5D8AA8"  
$Form.maximumsize = New-Object System.Drawing.Size(500, 300)  
$Form.startposition = "centerscreen"  
$Form.KeyPreview = $True  
$Form.Add_KeyDown({if ($_.KeyCode -eq "Escape")   
    {$Form.Close()}})  
  
$ListButton = new-object System.Windows.Forms.Button  
$ListButton.Location = new-object System.Drawing.Size(50,120)  
$ListButton.Size = new-object System.Drawing.Size(130,40)  
$ListButton.Text = "Pregled instaliranih programa"  
$ListButton.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(255, 255, 192);  
$ListButton.ImageAlign = [System.Drawing.ContentAlignment]::MiddleLeft;  
$Listbutton.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat  
$ListButton.Add_Click({listprograms})  
  
$Form.Controls.Add($ListButton)  
  
$address = new-object System.Windows.Forms.TextBox  
$address.Location = new-object System.Drawing.Size(65,60)  
$address.Size = new-object System.Drawing.Size(100,20)  
  
$Form.Controls.Add($address)  
  
$addresslabel = new-object System.Windows.Forms.Label  
$addresslabel.Location = new-object System.Drawing.Size(30,10)  
$addresslabel.size = new-object System.Drawing.Size(200,50)  
$addresslabel.Font = new-object System.Drawing.Font("Microsoft Sans Serif",12,[System.Drawing.FontStyle]::Bold)  
$addresslabel.Text = "Naziv radne stanice"  
$Form.Controls.Add($addresslabel)  
  
$programlabel = new-object System.Windows.Forms.Label  
$programlabel.Location = new-object System.Drawing.Size(270,10)  
$programlabel.size = new-object System.Drawing.Size(200,50)  
$programlabel.Font = new-object System.Drawing.Font("Microsoft Sans Serif",12,[System.Drawing.FontStyle]::Bold)  
$programlabel.Text = "Naziv progama za uklanjanje"  
$Form.Controls.Add($programlabel)  
  
$program = new-object System.Windows.Forms.TextBox  
$program.Location = new-object System.Drawing.Size(300,60)  
$program.Size = new-object System.Drawing.Size(100,20)  
  
  
$Form.Controls.Add($program)  
  
$UninstallButton = new-object System.Windows.Forms.Button  
$UninstallButton.Location = new-object System.Drawing.Size(50,180)  
$UninstallButton.Size = new-object System.Drawing.Size(130,40)  
$UninstallButton.FlatAppearance.MouseOverBackColor = [System.Drawing.Color]::FromArgb(255, 255, 192);  
$UninstallButton.ImageAlign = [System.Drawing.ContentAlignment]::MiddleLeft;  
$UninstallButton.Text = "Ukloni program"  
$Uninstallbutton.FlatStyle = [System.Windows.Forms.FlatStyle]::Flat  
$UninstallButton.Add_Click({remoteuninstall})  
  
$viclabel = new-object System.Windows.Forms.Label  
$viclabel.Location = new-object System.Drawing.Size(140,250)  
$viclabel.size = new-object System.Drawing.Size(200,50)  
$Form.Controls.Add($viclabel)  
  
$Form.Controls.Add($UninstallButton)  
  
$Form.Add_Shown({$Form.Activate()})  
$Form.ShowDialog() 


I evo kako to izgleda u praksi:

Unesite naziv udaljenog računara i klik na Pregled instaliranih programa






Nakon čega se otvori proyor sa spiskom instaliranih programa na toj radnoj stanici:
U polje Naziv programa za uklanjanje unesite tačan naziv programa i klik na Ukloni program,
po završetku će se pojaviti poruka da li je program uspešno uklonjen ili ne

Нема коментара:

Постави коментар