CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Run Add/Remove Programs from a program

    I want to be able via a program, to execute the Add/Remove Programs Utility and select a specific program or programs to remove. In other words make use of a command line types in a batch file, etc. I have not seen anything in documentation that suggest this is possible. Does anyone know?

    Thanks


  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Run Add/Remove Programs from a program

    I'm not sure what you mean by "make use of a command line types in a batch file", but this will bring up the Add/Remove Programs dialog in Win2000:


    option Explicit
    'Need reference to Microsoft Shell and Automation Controls
    private Sub Command1_Click()
    Dim sh as Shell
    set sh = new Shell
    sh.ControlPanelItem ("APPWIZ.CPL")
    set sh = nothing
    End Sub





  3. #3
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: Run Add/Remove Programs from a program

    You could download the CRegistry class from http://www.vbaccelerator.com

    and then use this code to get the values for the uninstallstring

    Dim c as new cRegistry
    Dim sKeys() as string, iKeyCount as Long
    Dim Uninstall as string

    With c
    .ClassKey = HKEY_LOCAL_MACHINE
    .SectionKey = "Software\Microsoft\windows\currentversion\uninstall"
    .EnumerateSections sKeys(), iKeyCount
    for iKey = 1 to iKeyCount
    .SectionKey = "Software\Microsoft\windows\currentversion\uninstall\" & sKeys(iKey)
    .ValueKey = "UninstallString"
    .ValueType = REG_SZ
    Uninstall = .Value
    next iKey
    End With



    Uninstall will hold the value after every loop
    That may get you started


  4. #4
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Re: Run Add/Remove Programs from a program

    Thanks. Yes I know about running this I just didn't make myself clear. What I wish to do is be able to select a program to remove from within another program or a script. For example is there somethign like the use of an additionl argument to select the program to remove: sh.ControlPanelItem ("APPWIZ.CPL", "program name")


  5. #5
    Join Date
    May 1999
    Location
    Fort Worth Texas
    Posts
    614

    Re: Run Add/Remove Programs from a program

    Thanks. I went to site you mentioned buit I could not find a reference to the CRegistry class you mentioned not then it turn up using their search tool.


  6. #6
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Run Add/Remove Programs from a program

    Don't think so.


  7. #7
    Join Date
    Feb 2000
    Location
    Ireland
    Posts
    808

    Re: Run Add/Remove Programs from a program


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured