how to display a message in console window?

Discussion in 'Javascript' started by thinktwice, Jan 18, 2006.

  1. thinktwice

    thinktwice Guest

    <package>
    <job id="js">
    <script language="JScript">
    var WshNetwork = WScript.CreateObject("WScript.Network");
    var oDrives = WshNetwork.EnumNetworkDrives();
    var oPrinters = WshNetwork.EnumPrinterConnections();
    WScript.Echo("Domain = " + WshNetwork.UserDomain);
    WScript.Echo("Computer Name = " + WshNetwork.ComputerName);
    WScript.Echo("User Name = " + WshNetwork.UserName);
    WScript.Echo();
    WScript.Echo("Network drive mappings:");
    for(i=0; i<oDrives.Count(); i+=2){
    WScript.Echo("Drive " + oDrives.Item(i) + " = " +
    oDrives.Item(i+1));
    }
    WScript.Echo();
    WScript.Echo("Network printer mappings:");
    for(i=0; i<oPrinters.Count(); i+=2){
    WScript.Echo("Port " + 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
     
    thinktwice, Jan 18, 2006
    #1
    1. Advertising

  2. thinktwice wrote:
    > <package>
    > <job id="js">
    > <script language="JScript">

    <snip>
    > </script>
    > </job>
    > </package>
    >
    > find an example in msdn, but it displays the message in
    > messagebox not in console window


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

    Richard.
     
    Richard Cornford, Jan 18, 2006
    #2
    1. Advertising

  3. thinktwice

    thinktwice Guest

    i call it in bat file,
    like this :
    cmd CScript /k C:\test.wsf
     
    thinktwice, Jan 18, 2006
    #3
  4. thinktwice

    DoomedLung Guest

    I'm kinda intermediate with Javascript, what is this type of syntax
    referencing to?
     
    DoomedLung, Jan 18, 2006
    #4
  5. thinktwice wrote:
    > i call it in bat file,
    > like this :
    > cmd CScript /k C:\test.wsf


    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.
     
    Richard Cornford, Jan 21, 2006
    #5
  6. thinktwice

    thinktwice Guest

    thanks Richard, it works
     
    thinktwice, Jan 25, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    1,016
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    493
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    656
    Serge Terekhoff
    Jun 30, 2003
  4. Miktor
    Replies:
    7
    Views:
    12,156
    Joe Bacigalupa
    Aug 9, 2005
  5. Replies:
    5
    Views:
    3,458
    James Kanze
    Mar 4, 2008
Loading...

Share This Page