I may have missed your API or scripting context, but here are two approaches that may help illustrate or help you achieve the goal:
MDL API (take a look at: ..\examples\IPCs\IPCNativeExample\IPCNativeExample.cpp+37)
...
int PublishFileWithMicroStation ()
{
// Modify the below path and filename to one that you want to publish
string seedFile = "c:\\test.dgn";
Bentley::WString seedPath(seedFile.c_str());
if (!FileExists(seedPath.c_str()))
{
cout << "Seed file " << seedFile << " does not exist. Use an existing dgn file." << endl;
return 0;
}ConnectionManager *cm = ConnectionManager::GetManagerObj();
// Find out how many registered engines there are
int count = cm->DiscoverEngines();
cout << "Number of engines found: " << count << endl;
...Scripting(e.g I use this to locate and use the most recent version of MicroStation and MicroStation SDK on my computer):
for /f "tokens=*" %%a in ('PowerShell -c "gp -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where {$_.Publisher -match """Bentley.*""" } | Where {$_.DisplayName -match """.*MicroStation """} | Where {$_.DisplayName -notlike """*PowerDraft*"""} | Where {$_.SystemComponent -match """1"""} | Sort-Object DisplayVersion | select -last 1 | select InstallLocation | ft -HideTableHeaders -AutoSize"') do set MS=%%~saMicroStation\
for /f "tokens=*" %%a in ('PowerShell -c "gp -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where {$_.Publisher -match """Bentley.*""" } | Where {$_.DisplayName -match """MicroStation.*SDK.*""" } | Sort-Object DisplayVersion | select -last 1 | select InstallLocation | ft -HideTableHeaders -AutoSize"') do set MSMDE=%%~saHTH,
Bob