Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to read a variable which is set within an executed batch file so I can verify it? (Vb.NET)

How to read a variable which is set within an executed batch file so I can verify it? (Vb.NET)

In your batch file, you can write the variable to a text file etc. This file can be added as an ActiveData asset in Workbench.

In your script you then load the ActiveData, pass the row value as a String and then use the Verify() method to verify if the value is correct.

Imports System.Diagnostics

Public Module Main

Dim _desktop As Desktop = Agent.Desktop

Public Sub Main()



End Sub


'function to verify ActiveData value

Private Function VerifyVariable()

Dim data As ActiveData = Workbench.LoadActiveData("ReadBatchVar")

Workbench.ResultComment("ActiveData loaded")

Dim row As ActiveDataRow = data.Item(1)

Dim batVal As String = row.GetString(1)

data.Dispose() '!Important - End loaded ActiveData


Workbench.Verify("expected", batVal)

End Function


End Module

You will also have a separate .Net script called 'ExecuteBatch' which calls the following function to execute the Batch File. 

'function to start process - batch file

Private Function ExecuteBatch()

Dim process As Process = Process.Start("C:\Temp\Batch.bat")

Workbench.ResultComment("Process Started")

End Function


Attached is a sample project which demonstrates how this can be done in Workbench .Net Script. This includes the above .Net scripts and the ActiveData asset and .txt file. You will need to point the ActiveData asset in Workbench to wherever you have it stored the .txt file. 



Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2015-04-16 10:20
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.