Using AutoIT to Uninstall

Author Message
fferrel

  • Total Posts : 11
  • Scores: 0
  • Reward points : 0
  • Joined: 5/21/2007
  • Status: offline
Using AutoIT to Uninstall Wednesday, May 23, 2007 3:41 AM (permalink)
0
OK I've been crunching through this for a week now and I finally think I'm getting somewhere.  I want to uninstall a game using a vbscript and hopefully AutoIt can get me through the uninstall without any user interaction.  My current code is...

 On Error Resume Next
 Set wshShell = WScript.CreateObject ("WSCript.shell")
 wshshell.run """C:\Program Files\Mario Forever\uninst.exe"""
 


I ran AutoIt Window Finder.

Title:  Mario Forever 4.0 Uninstall
Class:  #32770

Class: Button
Instance: 1

Which is a [yes] command

Title:  Mario Forever 4.0 Uninstall
Class:  #32770

Class: Button
Instance: 1

Which is an [ok] command

I've read through http://tiger.la.asu.edu/Quick_Ref/AutoIt_quickref.pdf  and http://www.visualbasicscript.com/m_43807/mpage_1/key_autoit/tm.htm#43891 which is a similar post.

With the information given above, along with my code, how can I accomplish this with?

Thank you,
Frank -
 
#1
    fferrel

    • Total Posts : 11
    • Scores: 0
    • Reward points : 0
    • Joined: 5/21/2007
    • Status: offline
    RE: Using AutoIT to Uninstall Wednesday, May 23, 2007 7:07 AM (permalink)
    0
    Just an update.  I am using the following code and it seems to be working.  Thank you AutoIt!

     On Error Resume Next
     
     Dim oShell
     Dim oAutoIt
     
     Set oShell = WScript.CreateObject("WScript.Shell")
     Set oAutoIt = WScript.CreateObject("AutoItx3.Control")
     
     oShell.Run """C:\Program Files\Mario Forever\uninst.exe""", 1, False
     
     OAutoIt.WinWaitActive "Mario Forever 4.0 Uninstall", "Do you really want to uninstall Mario Forever 4.0 and it's components?"
     
     oAutoIt.Send "!y"
     oAutoIt.Sleep 1000
     oAutoIt.WinWaitActive "Mario Forever 4.0 Uninstall", "Program Mario Forever 4.0 was successfully uninstall."
     oAutoIt.send "{Enter}"
     
     WScript.Quit
     
     
    Frank -
     
    #2
      dm_4ever

      • Total Posts : 3687
      • Scores: 82
      • Reward points : 0
      • Joined: 6/29/2006
      • Location: Orange County, California
      • Status: offline
      RE: Using AutoIT to Uninstall Wednesday, May 23, 2007 2:04 PM (permalink)
      0
      AutoIT must be installed on the PC's you intend to run this on.

      A probable better solution is to build it completely with AutoIT and package it into an EXE which it allows you to do...this way it is self contained.
      dm_4ever

      My philosophy: K.I.S.S - Keep It Simple Stupid
      Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
      Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
       
      #3
        fferrel

        • Total Posts : 11
        • Scores: 0
        • Reward points : 0
        • Joined: 5/21/2007
        • Status: offline
        RE: Using AutoIT to Uninstall Thursday, May 24, 2007 2:03 AM (permalink)
        0
        What would be the most efficient way to loop this incase only 1 of the 4 games are installed?  This was done solely with AutoIt.  I plan to have the .exe stored on a mapped drive and initiate it through a .vbs script.

         Run("C:\Program Files\LittleFighter2\LF2_v1.9c\uninst.exe")
         
         Sleep(3000)
         
         Run("C:\WINDOWS\MarioForever_Toolbar_Uninstaller_6484.exe")
         WinWaitActive("Mario Forever Toolbar Uninstaller")
         Send("!n")
         Sleep(1000)
         WinWaitActive("Mario Forever Toolbar Uninstaller")
         Send("!u")
         Sleep(4000)
         WinWaitActive("Mario Forever Toolbar Uninstaller")
         Send("!f")
         
         Sleep(3000)
         
         Run("C:\Program Files\Mario Forever\uninst.exe")
         WinWaitActive("Mario Forever 4.0 Uninstall")
         Send("!y")
         Sleep(2000)
         WinWaitActive("Mario Forever 4.0 Uninstall")
         Send("{Enter}")
         
         Sleep(3000)
         
         Run("C:\games\icytower1.3\unins000.exe")
         WinWaitActive("Icy Tower v1.3.1 Uninstall")
         Send("!y")
         WinWaitActive("Icy Tower v1.3.1 Uninstall")
         Send("{Enter}")
         
         

        Frank -
         
        #4
          dm_4ever

          • Total Posts : 3687
          • Scores: 82
          • Reward points : 0
          • Joined: 6/29/2006
          • Location: Orange County, California
          • Status: offline
          RE: Using AutoIT to Uninstall Thursday, May 24, 2007 2:27 AM (permalink)
          5
          This really isn't an AutoIT forum and I hardly use it, but looking at the docs there's a FileExists function

          Before you try to execute the unistall...check to see if it is there...i.e.

          If FileExists("C:\Program Files\LittleFighter2\LF2_v1.9c\uninst.exe") Then
              Run("C:\Program Files\LittleFighter2\LF2_v1.9c\uninst.exe")
          EndIf

          Sleep(3000)

          If FileExists("C:\WINDOWS\MarioForever_Toolbar_Uninstaller_6484.exe") Then
              Run("C:\WINDOWS\MarioForever_Toolbar_Uninstaller_6484.exe")
              WinWaitActive("Mario Forever Toolbar Uninstaller")
              Send("!n")
              Sleep(1000)
              WinWaitActive("Mario Forever Toolbar Uninstaller")
              Send("!u")
              Sleep(4000)
              WinWaitActive("Mario Forever Toolbar Uninstaller")
              Send("!f")
          EndIf
          .....code

          dm_4ever

          My philosophy: K.I.S.S - Keep It Simple Stupid
          Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
          Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm
           
          #5
            fferrel

            • Total Posts : 11
            • Scores: 0
            • Reward points : 0
            • Joined: 5/21/2007
            • Status: offline
            RE: Using AutoIT to Uninstall Thursday, May 24, 2007 2:37 AM (permalink)
            0
            I apologize for posting an AutoIt question.

            The FileExist function does work.  Thank you for all of your help.
            Frank -
             
            #6
              mbouchard

              • Total Posts : 2110
              • Scores: 29
              • Reward points : 0
              • Joined: 5/15/2003
              • Location: USA
              • Status: offline
              RE: Using AutoIT to Uninstall Thursday, May 24, 2007 5:25 AM (permalink)
              0
              Do not worry about asking questions here if it isn't a VBscript question, some but not all of us use AutoIT.  But since it isn't a VBscript question, this will be moved to the other languages forum, or what ever it is called.

              With that out of the way, one question I have is, since it seems that the window titles are the same, might there be text in the window that would be different?  This way if your first send keys might have failed (i.e. sent to the wrong window) it will be certain to be on the correct window.

              For example: (I only undated 1, and added DM's suggestion for using FileExists)
               
               ;If this is a command that runs silently, you can use RunWAIT instead of Run, RunWait is similar to VBscripts WaitOnReturn = True
               RunWait("C:\Program Files\LittleFighter2\LF2_v1.9c\uninst.exe")
               
               Sleep(3000)
               
               If FileExists("C:\WINDOWS\MarioForever_Toolbar_Uninstaller_6484.exe") Then
                   Run("C:\WINDOWS\MarioForever_Toolbar_Uninstaller_6484.exe")
                   WinWait("Mario Forever Toolbar Uninstaller")
                   WinActivate("Mario Forever Toolbar Uninstaller")
                   Send("!n")
                   Sleep(1000)
                   WinWait("Mario Forever Toolbar Uninstaller")
                   WinActivate("Mario Forever Toolbar Uninstaller")
                   Send("!u")
                   Sleep(1000)
                   WinWaitActive("Mario Forever Toolbar Uninstaller")
                   WinActivate("Mario Forever Toolbar Uninstaller")
                   Send("!f")
               EndIf
               
               Sleep(3000)
               
               If FileExists("C:\Program Files\Mario Forever\uninst.exe") Then
                   Run("C:\Program Files\Mario Forever\uninst.exe")
                   WinWaitActive("Mario Forever 4.0 Uninstall")
                   Send("!y")
                   Sleep(2000)
                   WinWaitActive("Mario Forever 4.0 Uninstall")
                   Send("{Enter}")
               EndIf
               
               Sleep(3000)
               
               If FileExists("C:\games\icytower1.3\unins000.exe") Then
                   Run("C:\games\icytower1.3\unins000.exe")
                   WinWaitActive("Icy Tower v1.3.1 Uninstall")
                   Send("!y")
                   WinWaitActive("Icy Tower v1.3.1 Uninstall")
                   Send("{Enter}")
               EndIf
               


              If you notice, I changed your winwaitactive to WinWait and then added a WinActivate.  My reasons for this are: WinWaitActive waits for the window to become active, move to the front of everything) and if that never happens your script would hang.  Using WinWait in it's place causes your script to wait till the window exists, does not have to be active, then it will activate the window and sendkeys to it.  Additionally, using WinWait you should not need to sleep as much, so I lowered those times.

              With all that said, I have not tested this and have not worked with the uninstall for the apps, so you would be better to tell if the above will work or not.

              Mike

              For useful Scripting links see the Read Me First stickey!

              Always remember Search is your friend.
               
              #7
                fferrel

                • Total Posts : 11
                • Scores: 0
                • Reward points : 0
                • Joined: 5/21/2007
                • Status: offline
                RE: Using AutoIT to Uninstall Thursday, May 24, 2007 6:25 AM (permalink)
                0
                Thank you for the info on WinWait and WinActivate.  The above code does work however I added an If Then to the first game.
                Frank -
                 
                #8
                  mbouchard

                  • Total Posts : 2110
                  • Scores: 29
                  • Reward points : 0
                  • Joined: 5/15/2003
                  • Location: USA
                  • Status: offline
                  RE: Using AutoIT to Uninstall Thursday, May 24, 2007 6:29 AM (permalink)
                  0
                  Glad to help.  One last thing, with AutoIT you can display a non-modal message to warn people not to mess with the mouse and keyboard while you do the uninstall.  Take a look at SplashTextOn
                  Mike

                  For useful Scripting links see the Read Me First stickey!

                  Always remember Search is your friend.
                   
                  #9

                    Online Bookmarks Sharing: Share/Bookmark

                    Jump to:

                    Current active users

                    There are 0 members and 1 guests.

                    Icon Legend and Permission

                    • New Messages
                    • No New Messages
                    • Hot Topic w/ New Messages
                    • Hot Topic w/o New Messages
                    • Locked w/ New Messages
                    • Locked w/o New Messages
                    • Read Message
                    • Post New Thread
                    • Reply to message
                    • Post New Poll
                    • Submit Vote
                    • Post reward post
                    • Delete my own posts
                    • Delete my own threads
                    • Rate post

                    2000-2012 ASPPlayground.NET Forum Version 3.9