Forum Discussion

yoni's avatar
yoni
New Contributor
15 years ago

Dynamically change the Application path between 64 vs 32 bit machines

Hi, 



I'm testing a 32bit application on windows 7 64bit and on Vista 32bit machines. The application's path is different on each machine (Program Files vs. Program Files(x86) ) 

I would like to create a project variable that will dynamically store the path according to the machine (it runs using TestExecute) and will be used in the TestedApps Editor.



Any Ideas?



Can someone share some code?



Thanks,

Y. 


15 Replies


  • Hi Yehuda,



    Modify your script in the following way:





    Sub ChangeASaMenuPath () 

      Dim Application 

      Dim os64bits 

      Dim aSaMenu 

      os64bits = Sys.OSInfo.Windows64bit 

      Set aSaMenu = TestedApps.aSaMenu 

      If os64bits Then

        aSaMenu.Path = Replace(aSaMenu.Path,"Program Files","Program Files (x86)")

      Else

        aSaMenu.Path = Replace(aSaMenu.Path,"Program Files (x86)","Program Files")  

      End If

    End Sub

  • QAPitt's avatar
    QAPitt
    Occasional Contributor
    Thanks David and everyone else for your help. That last post by David with the VBScript works exactly the way I was hoping!
  • QAPitt's avatar
    QAPitt
    Occasional Contributor
    David,



    Is there a way to run that as a code snippet at the beginning of a keyword test? or should i just call it using the Run Script Routine?
  • QAPitt's avatar
    QAPitt
    Occasional Contributor
    FYI, I changed your code slightly because on a 64 bit environment when the Else statement took place it was changing "Program Files (x86)" to "Program Files (x86) (x86)" etc.



    Here is the final version of the code I came up with:



    Sub ChangeASaMenuPath ()  

      Dim Application  

      Dim os64bits  

      Dim aSaMenu  

      os64bits = Sys.OSInfo.Windows64bit  

      Set aSaMenu = TestedApps.aSaMenu  

      

      If (os64bits = True) And aSaMenu.Path = "C:\Program Files\aSa\CI\" Then 

        aSaMenu.Path = Replace(aSaMenu.Path,"Program Files","Program Files (x86)") 

      End If  

      

      If (os64bits = False) And aSaMenu.Path = "C:\Program Files (x86)\aSa\CI\" Then

        aSaMenu.Path = Replace(aSaMenu.Path,"Program Files (x86)","Program Files")  

      End If 

    End Sub 
    Thanks again for all the help.

  • Hi Yehuda,



    You need to use Run Script Routine as the routine contains more than one line of code.