Running this code snippet:
use Win32::OLE;
$lrEngine = Win32::OLE->new('wlrun.LrEngine');
$lrScenario = $lrEngine->Scenario();
$rc = $lrScenario->new(0, 1);
# do not save previous
# regular vusers based scenario
$scriptLocation = 'PATH\TO\SCRIPTNAME\SCRIPTNAME.usr';
$scriptName = 'SCRIPTNAME';
$lrScenario->Scripts->Add($scriptLocation, $scriptName);
print "Win32::OLE::LastError: ".Win32::OLE::LastError()."\n";
Yields:
Win32::OLE::LastError: Win32::OLE(0.1709) error 0x80020005: "Type mismatch"
in METHOD/PROPERTYGET "Add" argument 2
Yes, the code passes string, even changing the code to force COM BSTR usage still generates the same error message
use Win32::OLE::Variant;
$scriptName = Variant(VT_BSTR, 'SCRIPTNAME');
What gives? The code definitely follows the documentation to the dot
Function Add(Path As String, Name As String) As Long
Add Script to Scenario
The answer: Variants by reference, changing the code, to reflect the snippet below, fixes the problem.
use Win32::OLE::Variant;
$scriptName = Variant(VT_BSTR|VT_BYREF, 'SCRIPTNAME');