how to display a message in console window?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thinktwice

    how to display a message in console window?

    <package>
    <job id="js">
    <script language="JScri pt">
    var WshNetwork = WScript.CreateO bject("WScript. Network");
    var oDrives = WshNetwork.Enum NetworkDrives() ;
    var oPrinters = WshNetwork.Enum PrinterConnecti ons();
    WScript.Echo("D omain = " + WshNetwork.User Domain);
    WScript.Echo("C omputer Name = " + WshNetwork.Comp uterName);
    WScript.Echo("U ser Name = " + WshNetwork.User Name);
    WScript.Echo();
    WScript.Echo("N etwork drive mappings:");
    for(i=0; i<oDrives.Count (); i+=2){
    WScript.Echo("D rive " + oDrives.Item(i) + " = " +
    oDrives.Item(i+ 1));
    }
    WScript.Echo();
    WScript.Echo("N etwork printer mappings:");
    for(i=0; i<oPrinters.Cou nt(); i+=2){
    WScript.Echo("P ort " + oPrinters.Item( i) + " = " +
    oPrinters.Item( i+1));
    }
    </script>
    </job>
    </package>

    find an example in msdn, but it displays the message in messagebox not
    in console window

  • Richard Cornford

    #2
    Re: how to display a message in console window?

    thinktwice wrote:[color=blue]
    > <package>
    > <job id="js">
    > <script language="JScri pt">[/color]
    <snip>[color=blue]
    > </script>
    > </job>
    > </package>
    >
    > find an example in msdn, but it displays the message in
    > messagebox not in console window[/color]

    Are you running it with WScript.exe or CScript.exe? CScript.exe should
    echo to the console window.

    Richard.


    Comment

    • thinktwice

      #3
      Re: how to display a message in console window?

      i call it in bat file,
      like this :
      cmd CScript /k C:\test.wsf

      Comment

      • DoomedLung

        #4
        Re: how to display a message in console window?

        I'm kinda intermediate with Javascript, what is this type of syntax
        referencing to?

        Comment

        • Richard Cornford

          #5
          Re: how to display a message in console window?

          thinktwice wrote:[color=blue]
          > i call it in bat file,
          > like this :
          > cmd CScript /k C:\test.wsf[/color]

          The - cmd - command starts another instance of the command interpreter
          process, but it does not open a console window for that process. If it
          did open a new console window then it would be to that window that echo
          would write, but as there is no console window popping up message boxes
          is probably what Microsoft see as the best alternative (especially given
          that CScript has a switch to turn off message output for batch file
          use).

          If you execute:-

          CScript C:\test.wsf

          - in a batch file (or literally in the console window) echo does write
          to that window.

          Richard.


          Comment

          • thinktwice

            #6
            Re: how to display a message in console window?

            thanks Richard, it works

            Comment

            Working...