OWASP O2 Platform Blog

O2 Script: Installing TortoiseSVN and ProcessExplorer

With the latests changes to the O2’s Windows Automation capabilities (that uses white API and Microsot’s UIAutomation API), it is now quite easy to create installers for commonly used tools.

Here are two examples, first for TortoiseSVN and then for SysInternals ProcessExplorer:

using System;
using System.Diagnostics;
using O2.Kernel;
using O2.Kernel.ExtensionMethods;
using O2.DotNetWrappers.ExtensionMethods;
//O2File:Tool_API.cs
//O2File:API_GuiAutomation.cs
//O2Ref:White.Core.dll
//O2Ref:UIAutomationClient.dll//O2File:_Extra_methods_To_Add_to_Main_CodeBase.cs
using O2.XRules.Database.Utils;

namespace O2.XRules.Database.APIs
{
    public class TortoiseSVN_Test
    {
        public void test()
        {
            new TortoiseSVN();//.start();
        }
    }
    public class TortoiseSVN : Tool_API
    {   
        public TortoiseSVN() : this(true)
        {
        }
       
        public TortoiseSVN(bool installNow)
        {
            config("TortoiseSVN", "TortoiseSVN 1.6.13.20954", "TortoiseSVN-1.6.13.20954-win32-svn-1.6.16.msi");           
            Install_Uri = "http://downloads.sourceforge.net/project/tortoisesvn/1.6.13/Application/TortoiseSVN-1.6.13.20954-win32-svn-1.6.16.msi".uri();
            Install_Dir = @"C:\Program Files\TortoiseSVN";
            if (installNow)
                install();           
        }
       
       
        public bool install()
        {
            "Installing {0}".info(ToolName);
            startInstaller_FromMsi_Web();                        
            if (this.Install_Process.notNull())
            {
                var guiAutomation = new API_GuiAutomation(this.Install_Process); 

                //step 1
                guiAutomation.windows()[0]
                             .button("Next >")
                             .mouse().click();
                //step 2
                var acceptTerms  = guiAutomation.windows()[0]; 
                acceptTerms.radioButton("I accept the terms in the License Agreement")
                           .mouse().click() ;
                acceptTerms.button("Next >")
                           .mouse().click(); 
                //step 3
                guiAutomation.windows()[0]
                             .button("Next >")
                             .mouse().click();
                //step 4
                guiAutomation.windows()[0]
                             .button("Install")
                             .mouse().click();
                //step5                   
                            for(int i = 0 ; i< 20; i ++)
                            {
                                this.sleep(2000,true); // wait 2 secs and try again 
                                var tortoiseGitSetup  = guiAutomation.windows()[0]; 
                                if (tortoiseGitSetup.button("Next >").isNull())
                                {
                                    tortoiseGitSetup.button("Finish").mouse().click();  
                                    break;
                                }                       
                            }
            }
            return isInstalled();
        }       
    }
}

 

using System;
using System.Diagnostics;
using O2.Kernel;
using O2.Kernel.ExtensionMethods;
using O2.DotNetWrappers.ExtensionMethods;
//O2File:Tool_API.cs//O2File:_Extra_methods_To_Add_to_Main_CodeBase.cs
using O2.XRules.Database.Utils;

namespace O2.XRules.Database.APIs
{
    public class Install_PE_Test
    {
        public void test()
        {
            new ProcessExplorer().start();
        }
    }
    public class ProcessExplorer : Tool_API
    {   
        public ProcessExplorer() : this(true)
        {
        }
       
        public ProcessExplorer(bool installNow)
        {
            config("ProcessExplorer", "ProcessExplorer v14.1", "ProcessExplorer.zip");           
            Install_Uri = "http://download.sysinternals.com/Files/ProcessExplorer.zip".uri();
            if (installNow)
                install()           
        }
       
       
        public bool install()
        {
            "Installing {0}".info(ToolName);
            return installFromZip_Web();                        
        }
       
        public Process start()
        {
            if (install())
                return Install_Dir.pathCombine("procexp.exe").startProcess();
            return null;
        }       
    }
}

March 18, 2011 - Posted by | Interoperability

2 Comments »

  1. I found the post very interesting. But can I ask you a question. Why do you use TortoiseSVN? I highly recommend you to try GIT. It is really the best way to manage all your development process and code changes.

    Comment by Developer | March 20, 2011 | Reply

    • As you can see by the recent O2 scripts I posted here, I’m thinking of moving O2’s code to Git and GitHub 🙂

      Comment by o2platform | March 20, 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: