Using VB scripting to automate an application

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Reza
Newbie
Newbie
Posts: 2
Joined: Mon Feb 18, 2019 8:10 pm

Using VB scripting to automate an application

Post by Reza »

Hello!
I have been using an windows simulation application for quite some time now. I would have to simulate the model multiple times with necessary perturbations. In order to make this process automatic I have been using vbscript which would make the necessary changes within the model on that application and run and record the output. Because of the necessity of a large number of simulations requirement, I am trying to run the model on a centos server through WINE. So far, I have been able to run the application on the server through wine. Can I use a vb script to automate the process like it was possible on windows?
Thanks,
Reza
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: Using VB scripting to automate an application

Post by Bob Wya »

@Reza

You may find it's more optimal to automate the cloning of a number of identical WINEPREFIX's, with different datasets, and run these in parallel (e.g. with a native Linux python,BASH,etc. script).
Each WINEPREFIX will have it's own dedicated wineserver process then.

This is because wineserver can quickly become a bottleneck, as all your Wine threads communicate via this central process.
The wine-esync patchset was developed to mitigate some of the wineserver overheads (for synchronisation primitives anyway).

But VB scripting should be fine, to automate this process. Especially if raw performance isn't a primary concern.

Bob
Reza
Newbie
Newbie
Posts: 2
Joined: Mon Feb 18, 2019 8:10 pm

Re: Using VB scripting to automate an application

Post by Reza »

I can use vbs to run the program now. Here is a sample of the vb script.

Code: Select all

Function Sleep(sec)
WScript.Sleep (sec * 1000)
End Function


'Part 1: open the model
Set W = CreateObject("WEAP.WEAPApplication")
W.ActiveArea = "TRWD system operation_daily TS_quarterly forecast model"
' Make sure WEAP is fully started
While Not W.ProgramStarted
Sleep (1)
Wend
'Part 2: ensuring Current accounts is the active scenario
IF NOT W.ActiveScenario = "Current Accounts" THEN
W.ActiveScenario = "Current Accounts"
END IF
'Part 3: Change input as necessary
'14. sensitivity to benbrook pumping threshold
W.Branch("Key\BB\BB flood pumping\Flood pumping threshold").Variables("Annual Activity Level").Expression =  arrFields(1)
'Part 4: load and export results 
W.LoadFavorite ("Unmet Demand")
CALL W.ExportResults ("C:\Research\WEAP results\sensitivity analysis\trial\1\Unmet_Demand.csv", , , TRUE)
This script runs without any issues on windows. However, when run on wine it does everything except the last line where it is calling the required function to export the results from the application. On this line, it shows 'Type mismatch error'. Can anyone here kindly help me with this?
Thanks
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Re: Using VB scripting to automate an application

Post by lahmbi5678 »

Maybe there's a bug in wine. Could you try the last line with only the filename, e.g. "Demand.csv" (instead of the full path), to make sure, that wine doesn't have issues with the path, e.g. "\" might get lost, maybe it would work with "\\", but that's just a guess. And maybe insert values for all parameters (",,,"), if there are reasonable values.

Did you install WSH with winetricks, e.g. "winetricks wsh57"?

Anyways, you should file a bug report with all your findings.
User avatar
Bob Wya
Level 12
Level 12
Posts: 3068
Joined: Sat Oct 16, 2010 7:40 pm

Re: Using VB scripting to automate an application

Post by Bob Wya »

lahmbi5678 wrote:... Could you try the last line with only the filename, e.g. "Demand.csv" (instead of the full path), to make sure, that wine doesn't have issues with the path, e.g. "\" might get lost, maybe it would work with "\\", but that's just a guess. ...
I don't think the forward slashes will need escaping in the context of a VB script.
Although a quick run with strace, or enabling debugging for Wine's path / file handling, could be checked by OP.

Bob
Locked