Script Command.RunCommand wait till completed

In a script I would like to execute a dos command wait till it finishes then perform some other tasks.

Here is what I'm currently doing. The line after the RunCommand is executed before the RunCommand has finished.

  var doCmd = DOpus.NewCommand;
  var cmd = "c:\\CreateBigfiles.exe c:\\mynewbigfile.dat";
  doCmd.RunCommand(cmd);

  var mynewFIle = DOpus.FSUtil.GetItem("c:\\mynewbigfile.dat")

If you put @sync: in front of the command does it work?

This give me an error about the file not being found at the RunCommand line.

  var doCmd = DOpus.NewCommand;
  var cmd = "@sync: c:\\CreateBigfiles.exe c:\\mynewbigfile.dat";
  doCmd.RunCommand(cmd);

  var mynewFIle = DOpus.FSUtil.GetItem("c:\\mynewbigfile.dat")

Based on your comment I also tried this. Didn't work though.

  var doCmd = DOpus.NewCommand;
  var cmd = "@sync:c:\\CreateBigfiles.exe c:\\mynewbigfile.dat";
  doCmd.SetModifier("sync");
  doCmd.RunCommand(cmd);

  var mynewFIle = DOpus.FSUtil.GetItem("c:\\mynewbigfile.dat")

No wait, adding @sync: did work. Need to have a space after it though.
Thanks Jon

  var doCmd = DOpus.NewCommand;
  var cmd = "@sync: c:\\CreateBigfiles.exe c:\\mynewbigfile.dat";
  doCmd.RunCommand(cmd);

  var mynewFIle = DOpus.FSUtil.GetItem("c:\\mynewbigfile.dat")

Correction, the reason adding @sync: didn't work at first was because I had a space before the @.

This does not work

var cmd = " @sync:c:\\CreateBigfiles.exe c:\\mynewbigfile.dat";

This does

var cmd = "@sync:c:\\CreateBigfiles.exe c:\\mynewbigfile.dat";
1 Like