Forum Discussion

nikki85's avatar
nikki85
Contributor
7 years ago

Uninstall desktop application from control panel by VB script

Sub UninstallApplication(computerName, applicationName)

  Dim wmiService, objectsList, ObjService
  Set wmiService = GetObject("WinMgmts:{impersonationLevel=impersonate}!\\"& computerName & "\root\cimv2")
  Set objectsList = wmiService.ExecQuery("SELECT * FROM Win32_Product " & "WHERE Name='" & applicationName & "'")

  For Each ObjService in ObjectsList

   ObjService.Uninstall()
  Next
End Sub

 


it works fine for me in windows 7 ; but not for windows 10, i want something similar to work in windows 10.

3 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    You really haven't given us any information to work with here.  What happens when you try it in Windows 10?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Keep in mind Windows 10 UAC is much different than Windows 7.  It could be that Windows 10 UAC is set to a level that does not allow that uninstall.  Try adjusting the UAC settings on your Windows 10 box to the lowest setting and try again.