Delete Software

Uninstalls a hypothetical software program (Personnel database) installed using Windows Installer.

4.2 Star
Add to favorites
E-mail Twitter Digg Facebook
Sign in to ask a question

  • Why doesn't this work in SCCM 2007?
    1 Posts | Last post October 28, 2012
    • This code unfortunately didn't work for me deploying through sccm 2007. It would remove the app data in program files but would leave the installer in add/remove. If ran locally it ran fine.
  • Looks Good!
    4 Posts | Last post September 08, 2012
    • I am a beginner so sorry if this is a dumb but here goes (taking a deep breath!)-
      I have added a reference to and rewriten the code as shown below:-
      Public Sub UninstallPCS()
      'Uninstalls PCS7 that was installed using Windows Installer.
      Dim objSoftware As Object
      Dim strComputer As String = "."
      Dim objWMIService As Object = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Dim colSoftware As Array = objWMIService.ExecQuery("Select * from Win32_Product Where Name = 'PCS7'")
      MsgBox("Uninstalling the PCS Application.", MsgBoxStyle.Exclamation, "Trial Period Over-extended")
      For Each objSoftware In colSoftware
           If MsgBox("Do you really want to un-install " & objSoftware.tostring) = MsgBoxResult.Yes Then
           End If
      End Sub
      I think this doesn't work because I have not correctly declared the variable types.
      What should they be?
      (The error message is "An unhandled exception of type 'System.InvalidCastException' occurred in PCSUnInstaller.exe
      Additional information: Specified cast is not valid.")
    • Sorry, what's the advantage? Thanks!
    • Ya, what's the advantage?
    • ya whats the best part there.........