Forum Discussion

simon_cnhi's avatar
simon_cnhi
Occasional Contributor
4 years ago

How to use a project variables in a VB script unit

Hi all,

I have come across a problem, that I cannot fathom.
I have 4 values I will be using across a suite of tests I am defining. I have created persistent project variables to store these values (LAA = Local Admin account)

I am launching a CMD prompt using the local administrator account, because using certain WMIC commands require to be executed as the local admin account, e.g. WMIC USERACCOUNT.

I know the LAAPassword project variable is typed as a string in the screenshot, but this is irrelevant because I have the exact same failure when the LAAPassword variable is typed as a password

The following VB script fails to launch a batch file, and errors with 'Unable to run "GenLAAProps_app" under the domain\account name"

If I define the variables within the VB script, e.g. LAAName = "CantGuessMe", etc. then the script works. Because of the way we do security, different Windows installations have different local admin names and passwords, which I wish to feed-in via a datasource, hence the reason for using project variables - this input will be developed once I can get the project variables to work.

I've also tried assigning the project variables to local variables defined within the VB script, but no luck.

 

It's probably something very simple I've missed out, but I can't find it.
Any help would be welcomed.

Cheers,

Simon

  • What version of TestComplete are you using?

     

    Try posting each variable out to the test log and see if it actually has the value that you expect.

    • simon_cnhi's avatar
      simon_cnhi
      Occasional Contributor

      Thanks for the suggestion. I will give this a go.
      My version of TestComplete is;

      • simon_cnhi's avatar
        simon_cnhi
        Occasional Contributor

        Changing the project variables to be defined as "Temporary Variables" allows the VBscript to access them within the project!

         

        probably there is something else I need to do to reference the variables when they are defined as "Persistent Variables" - damned if I know what though! But, have a workaround now.

         

        cheers

        Simon

  • tklemensen's avatar
    tklemensen
    New Contributor

    This may not be the issue, but I had an issue with encrypted passwords entering consistently in forms.  I found that using the .DecryptedValue or something similar after the variable name made it work all the time.

     

    Example:  textbox.Keys(Project.Variables.VariableName.DecryptedValue)

     

    Posting this in case it helps someone.