Windows Azure Cloud Storage ermöglicht es Ihnen bereits ab 0,10€ pro GB/Monat die Vorteile der Cloud zu nutzen.
Willkommen bei dotnet-snippets.de! Snippet hinzufügen Login Registrieren
Snippets in der Datenbank: 1550 | Anzahl registrierter User: 1840 | Besucher online: 67
Hauptmenü
Home
Top Ten
Zufälliger Snippet
FAQs
.NET Community
dotnet-forum.de
dotnet-kicks.de
Social

RSS Feeds
Rss Alle Snippets
Rss C#
Rss VB.NET
Rss C++
Rss ASP.NET
Partner
Member of Microsoft Community Leader/Insider Program (CLIP)

Anwendung deinstallieren


Autor: Volker Steitz
Sprache: VB.NET
Bewertung:
8.62 (5 votes)
Anzahl der Aufrufe: 7672
  
Kick it on dotnet-kicks.de  

Beschreibung:

Mit wenigen Zeile code aus einer Anwendung heraus eine installierte Anwendung deinstallieren (Quick and Dirty Lösung).

Abgelegt unter: UnInstall, Install, WMI.



Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim sName As String = String.Empty
        Dim sMachineName As String = String.Empty
        Dim sAdminUser As String = String.Empty
        Dim sPassword As String = String.Empty
        Dim oService As Object
        Dim oLocator As Object



        sMachineName = InputBox("Bitte geben Sie den Computern an!")
        sAdminUser = InputBox("Enter the admin user name.")
        sPassword = InputBox("Enter the users password. ")
        oLocator = CreateObject("WbemScripting.SWbemLocator")

        'connect to remote machine
        oService = oLocator.ConnectServer(sMachineName, "root\cimv2", sAdminUser, sPassword)

        'get a list of installed products
        Dim sMsg As String = String.Empty

        For Each oProduct As Object In GetObject("winmgmts:{impersonationLevel=impersonate,(Debug)}").InstancesOf("win32_Product")

            'Wollen wir wirklich das Ausgewählte Produkt deinstallieren?
            sMsg = "Product: " & vbCrLf
            sMsg = sMsg & oProduct.Name
            sMsg = sMsg & vbCrLf & "Continue uninstalling?"

            If MsgBox(sMsg, 4) = 6 Then
                sName = oProduct.Name
                Exit For
            End If

        Next

        Try
            'Get the named package of the selected Product
            For Each oProduct As Object In GetObject( _
             "winmgmts:{impersonationLevel=impersonate}" _
             ).ExecQuery _
             ("Select * from Win32_Product where Name='" & sName & "'")
                'uninstall selected Product	
                oProduct.Uninstall()
                'done!
                MessageBox.Show("Uninstalled " & sName, "Operation Complete", MessageBoxButtons.OK)

            Next
        Catch ex As Exception
            MessageBox.Show(ex.Message & sName, "Operation NOT Completed", MessageBoxButtons.OK)
        End Try

    End Sub
Sie haben Fragen zu diesem Snippet oder brauchen Hilfe bei der .NET Entwicklung?
Freundliche und kompetente Entwickler helfen Ihnen gern weiter im Forum für .NET Entwicklung.



Kommentare:
(Zum Schreiben von Kommentaren bitte anmelden.)



schlecht sehr gut
1 2 3 4 5 6 7 8 9 10
Nur angemeldete User können Snippets bewerten.