Here is an example using VB script. Save the following lines as a text file (e.g., test.vbs), then double-click on the text file in Windows Explorer to run it.
' Run WEAP as a COM Automation Server
' Do a sensitivity analysis on the Supply Measures scenario to the population growth rate of South City
' Vary the population growth for South City from 0 to 5%, saving groundwater storage results for each run in c:\GWn.csv
Set WEAP = CreateObject("WEAP.WEAPApplication")
WEAP.Verbose = 1 ' 0 = no dialogs, 1 = errors only, 2 = questions and errors, 3 = warnings, questions and errors, 4 = all dialogs
WEAP.Logfile = WEAP.Directory + "WeapErrors.txt" ' log all errors and warnings to this text file
WEAP.ActiveArea = "Weaping River Basin"
WEAP.ActiveScenario = "Supply Measures"
FOR GrowthRate = 0 to 5
WEAP.Branch("\Demand Sites\South City").Variables("Annual Activity Level").Expression = "Growth(" + FormatNumber(GrowthRate, 0) + "%)"
CALL WEAP.LoadFavorite("Groundwater Storage") ' This will calculate first
IF WEAP.Status = FALSE THEN ' If the user cancels the calculations, exit the FOR loop
EXIT FOR
END IF
CALL WEAP.ExportResults("c:\GW" + FormatNumber(GrowthRate, 0) + ".csv", FALSE, TRUE)
NEXT
' WEAP will close automatically when the script is done, and the changes will NOT be saved to the area