1 Reply Latest reply on Jun 28, 2007 10:05 AM by Tobias Frech

    How do I automate close of Windows command line interface?

    Larry Newbie

      When script below runs, the Windows CLI remains open until manually closed. I want to run as a scheduled background process but, need to force CLI to close once command has executed to prevent process from hanging. Any/All suggestions appreciated.

      Thanks, lea

      main();

      function main()
      {
      // get contents of the \\stlmombhftp1\MKSTest\Outbound folder and load into array fc

      var fso, f, f1, fc, intIndex;
      fso = new ActiveXObject("Scripting.FileSystemObject");
      f = fso.GetFolder("//stlmombhftp1/MKSTest/Outbound");
      fc = new Enumerator(f.files);

      // for each file found in array fc, attach to the issue, copy file to the
      // \\stlmombhftp1\MKSTest\ArchiveOutbound and remove from \\stlmombhftp1\MKSTest\Outbound.

      for (; !fc.atEnd(); fc.moveNext())
      {
      // extract the filepath from \\stlmombhftp1\MKSTest\Outbound forward and extract the ID number
      // from the filename and create the file destination variable for later use in moving the file.

      var strfilepath = fc.item();
      var strfilesource = String(strfilepath);
      var strfilename = String(strfilepath);
      intIndex=strfilename.lastIndexOf("RP");
      strfilename=strfilename.substr(intIndex);
      var strid=strfilename.substr(2,4);

      // write the cli command and execute.

      var strcli = "im editissue --port=7001 --hostname=stlmoapp07 --user=MKSScript --password=P2bbl357 --addAttachment='" + strfilepath + "' " + strid;
      var WshShell = new ActiveXObject("Wscript.Shell");
      var oExec=WshShell.Exec(strcli);

      // WScript.Echo(strcli);
      // oExec.StdOut.ReadAll();

      // move the file to the ArchiveOutbound directory and remove from the Outbound directory

      var strfiledest=strfilesource.substr(0,23) + "ArchiveOutbound\\" + strfilename;
      var strfiledup=strfilesource.substr(0,23) + "ArchiveOutbound\\Dup" + strfilename;

      if (fso.FileExists(strfiledest)) {
      if (fso.FileExists(strfiledup)) {
      fso.CopyFile(strfilesource,strfiledup);
      fso.DeleteFile(strfilesource); }
      else {
      fso.MoveFile(strfilesource,strfiledup); }
      }
      else {
      fso.MoveFile(strfilesource,strfiledest); }
      }

      }