Ask a Question

How to use a project variables in a VB script unit

Occasional Contributor

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)

persistent project variables.png

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"

VB script unit.png

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.



Community Hero

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.

[Community Hero]
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
Occasional Contributor

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


Occasional Contributor

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

temporary project variables.png


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.




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.

Showing results for 
Search instead for 
Did you mean: