Pre-process before open dialog (sync)

Hi all

I may have asked this already ~2 years ago but couldn' find the post. But I wonder if there is now a solution for my problem. I have a function
calling a DOS Batch (doCmd.RunCommand)
the Batch file defines some environment variables
I read the environment variables ( var foo = fs.Resolve("%bar%"); ) and
display the values in a dialog.

Problem is that the dialog pops up before the batch has finished and need somehow a sync
here. Any ideas or recommendations.

Aloha
Uwe

It can depend what the command is, but adding "@sync:" to the start of the command line may be all you need.

Hi Leo

Thansk - I know @sync and tried that in various combinations (including tab modifier) but I get always an parser error. Currently I have
function OnClick(data) {
var doCmd = DOpus.NewCommand;
doCmd.RunCommand("d:/use/do_ixiasoftservices.bat");
....

Aloha
Uwe

A batch file run like that probably won't affect the env-vars outside of the batch file itself.

Also check that the commands the batch runs are actually synchronous. If you run it from a command prompt, does it return before the things it runs are finished? If so then the issue is with the batch file and what it runs, not with how the batch file is being run.

If you want Opus to wait until the batch file is finished, you need to call it via WScript.Shell and Run().

You'll find a working example e.g. here:

Hi lxp
Tried WScript.Shell already without succes but thnaks for your example.

So it seems that Leo is right and I have problems in my bathc file (though ir says SUCCESS in a command prompt before my "pause"). Shenanigan seems to be

sc queryex "TextmlServer44" | findstr RUNNING
IF NOT ERRORLEVEL 1 setx -m uwetemp_textmlserver 1

If I remove that and define the envionment variable manually everything is fine.

So I need a totally another way to figure out whether a service is running or not.

Thanks for your help

Aloha
Uwe

Hi all

Phew - Just to let you know that I have a solution:

  var doCmd = DOpus.NewCommand;
  doCmd.AddLine("@sync:cmd /c d:/use/do_servicesixiasoft.bat");
  doCmd.Run;

or

  var doCmd = DOpus.NewCommand;
  doCmd.RunCommand("@sync:cmd /c d:/use/do_servicesixiasoft.bat");

But I am still unsuccessful with WshShell; does not work in line and get errors when I use the modfier @sync.

Anyway, works now and thanks for your inputs.

Aloha
Uwe