Jump to content

Uninstalling an app


Paradox
 Share

Recommended Posts

Getting tired of questions from me yet?? ;)

So here's the next one. I now have to code in a function to repair/reinstall my company's apps if the user needs too. Unfortunately, there's no direct uninstall program that I can run, so really my only option is to use that Add/Remove programs applet from the control panel.

I powered up the Win Info Tool, and to my dismay, I noticed that there is no identifing markings on either the Add/Remove button from the control panel, or in the actual list itself... I can see how this could be a big dilemma.

My only thought though is that all of the apps that I'll have to work with have a uninst.isu file that I know windows has to read from when it uninstalls the program. Anyone have any clue how to go around windows and uninstall a program while using this file without using Add/Remove???

Link to comment
Share on other sites

You need the registry...

RegEnumKey()

and...

HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

and...

RegRead()

and...

DisplayName

and...

RegRead()

and...

UninstallString

Lar.

<{POST_SNAPBACK}>

Gee, you make it sound so simple!!! ;) In all honesty, Huh??? Edited by Paradox
Link to comment
Share on other sites

; see the name of program in Add/Remove? Put it here \/
$MYAPP = "My Add/Remove Appname here"

$UNINSTALLSTRING = GetUninstallString($MYAPP)

If Not @error Then Run($UNINSTALLSTRING)

Func GetUninstallString($app)
   $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"

   $i = 0
   While 1
      $i = $i + 1
      $subkey = RegEnumKey($key,$i)
      If @error Then ExitLoop
      $displayname = RegRead($key & "\" & $subkey,"DisplayName")
      If @error Then ContinueLoop
      If $displayname == $app Then
            Return RegRead($key & "\" & $subkey,"UninstallString")
      EndIf
   WEnd
   SetError(1)
   Return ""
EndFunc

<{POST_SNAPBACK}>

dude, You rock!
Link to comment
Share on other sites

Gee, you make it sound so simple!!! ;)  In all honesty, Huh???

<{POST_SNAPBACK}>

If you obtain the un-install string, then you can then run msiexec with the /x (un-install) and /quiet (no user interaction), let me give you an example. I am a moderate autoitcoder (probably less than that), but I do understand the way Windows installers work.

to un-install many applications that don't necessarily display an entry in add/remove program, go to the HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

section in the registry.

some apps will have a direct path to their un-installer like autoit for example

it's Un-install string value is: C:\Program Files\AutoIt3\Uninstall.exe

other apps were installed by MSI (likely your company's software), so look for the correct string. Here is one for .NET Framework.

MsiExec.exe /X{1A655D51-1423-48A3-B748-8F5A0BE294C8}

running that line above will remove the .NET Framework, if you add a /quiet before the /X, it will do it silently.

other applications call a .dll to perform the un-install routine for them, here is an example, for Google Earth (cool program!)

RunDll32 C:\PROGRA~1\COMMON~1\INSTAL~1\PROFES~1\RunTime\10\01\Intel32\Ctor.dll,LaunchSetup "C:\Program Files\InstallShield Installation Information\{3DE5E7D4-7B88-403C-A3FD-2017A8240C5B}\setup.exe" -l0x9 -removeonly

from what is displayed here, there is a "remove only" switch, this one is calling Installshield.

Depending on what method your company uses to deploy software, it will help determine the best way to get that software back on in the way it is supposed to be. If your company uses WISE, you wouldn't need to worry about un-installing, as you could have the WISE module check for the presence of the previous/corrupted version and then overwrite all files, registry settings, ini files, etc to get the application restored back to your company's defaults.

I hope this kind of helps, but admittedly, have not tried a way of performing these tasks using autoit yet.

Lexx

Link to comment
Share on other sites

; see the name of program in Add/Remove? Put it here \/
$MYAPP = "My Add/Remove Appname here"

$UNINSTALLSTRING = GetUninstallString($MYAPP)

If Not @error Then Run($UNINSTALLSTRING)

Func GetUninstallString($app)
   $key = "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall"

   $i = 0
   While 1
      $i = $i + 1
      $subkey = RegEnumKey($key,$i)
      If @error Then ExitLoop
      $displayname = RegRead($key & "\" & $subkey,"DisplayName")
      If @error Then ContinueLoop
      If $displayname == $app Then
            Return RegRead($key & "\" & $subkey,"UninstallString")
      EndIf
   WEnd
   SetError(1)
   Return ""
EndFunc

<{POST_SNAPBACK}>

Holy crap!.. that is sweet, you have just helped me with a completely different issue that I was trying to use to figure out how to extract the Distinguished Name from the registry without using ADSI to get it from a DC. Thanks man, you do rock, I feel ignorant for even posting what I posted after seeing what you just posted!.

How long did it take you to learn how to code like that, are you a natural coder.

I have written some autoit apps that do things like install printer drivers, setup wireless networks (using keystrokes and also using wlanprof.exe with xml to import profiles), but my apps have always suffered in the error checking portion, after seeing how you deal with errors, that is going to help me parse out the distinguished name, which I found daunting because I know that every machine out there has a unique SID for each user, but I didn't want my autoit code blowing up if it couldn't find the correct value in the registry.

Thanks, you helped me a lot today too!.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...