OWASP O2 Platform Blog

O2 Script: Automating TortoiseGit installation

Here is a script that uses O2’s support for the White API (which exposes the Microsof’s UIAutomation API) to automate the install and uninstall of the TortoiseGit appliation:

DOWNLOAD AND INSTALL

Action<string> install_TortoiseGit =
    (msiPath)=> {
                    var process = msiPath.startProcess();
                    var guiAutomation = new API_GuiAutomation(process); 
                    var tortoiseGitSetup  = guiAutomation.windows()[0];
                    //tortoiseGitSetup.bringToFront();
                    //step 1
                    tortoiseGitSetup.button("Next >").mouse().click(); 
                    //step2 
                    tortoiseGitSetup  = guiAutomation.windows()[0]; 
                    tortoiseGitSetup.radioButton("I accept the terms in the License Agreement").mouse().click() ;
                    tortoiseGitSetup.button("Next >").mouse().click(); 
                    //step3 
                    tortoiseGitSetup  = guiAutomation.windows()[0]; 
                    tortoiseGitSetup.button("Next >").mouse().click();  
                    //step4
                    tortoiseGitSetup  = guiAutomation.windows()[0]; 
                    tortoiseGitSetup.button("Next >").mouse().click();  
                    //step5
                    tortoiseGitSetup  = guiAutomation.windows()[0]; 
                    tortoiseGitSetup.button("Install").mouse().click(); 
                    //step6                   
                    for(int i = 0 ; i< 20; i ++)
                    {
                        this.sleep(2000,true); // wait 2 secs and try again
                        tortoiseGitSetup  = guiAutomation.windows()[0]; 
                        if (tortoiseGitSetup.button("Next >").isNull())
                        {
                            tortoiseGitSetup.button("Finish").mouse().click();  
                            break;
                        }                       
                    }
                };
var tortoiseGit_DownloadUrl = "http://tortoisegit.googlecode.com/files/Tortoisegit-1.6.5.0-32bit.msi";
var localMsi = tortoiseGit_DownloadUrl.download();install_TortoiseGit(localMsi);

UNINSTALL

Action<string> unInstall_TortoiseGit =
    (msiPath)=> {                   
                    var process = msiPath.startProcess();                    
                    var guiAutomation = new API_GuiAutomation(process);                     
                    //step 1
                    var tortoiseGitSetup  = guiAutomation.windows()[0]; 
                    tortoiseGitSetup.button("Next >").mouse().click(); 
                    //step 2
                    tortoiseGitSetup  = guiAutomation.windows()[0];
                    tortoiseGitSetup.button("Remove Installation").mouse().click();                      
                    //step 3
                    tortoiseGitSetup  = guiAutomation.windows()[0];
                    tortoiseGitSetup.button("Remove").mouse().click();                       
                    //step 4                   
                    for(int i = 0 ; i< 10; i ++)
                    {
                        this.sleep(2000,true); // wait 2 secs and try again
                        tortoiseGitSetup  = guiAutomation.windows()[0];
                        if (tortoiseGitSetup.button("Next >").isNull())
                        {
                            tortoiseGitSetup.button("Finish").mouse().click();  
                            break;
                        }                       
                    }
                };
unInstall_TortoiseGit(localMsi);

March 15, 2011 - Posted by | Interoperability

3 Comments »

  1. […] we have Tortoise installed (using an O2 Script) the next step is to create the SSH RSA keys using PuttyGen (which is include in […]

    Pingback by O2 Script: automating PuttyGen to create Public and Private Keys « O2Platform.com for Developers | March 16, 2011 | Reply

  2. […] we had TortoiseSVN  installed and used PuttyGen to create the SSH key we now need to add the SSH Key to the GitHub […]

    Pingback by O2 Script: adding the SSH to GitHub « O2Platform.com for Developers | March 18, 2011 | Reply

  3. […] installing  TortoiseGIT ,  using PuttyGen to create the SSH key and adding the SSH Key to GitHub the final step in this […]

    Pingback by O2 Script: Creating a Git Clone using TortoiseGIT « O2Platform.com for Developers | March 18, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: