how to display a message in console window?

  • Follow


<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

0
Reply thinktwice 1/18/2006 10:43:52 AM

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.


0
Reply Richard 1/18/2006 11:06:12 AM


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

0
Reply thinktwice 1/18/2006 11:33:34 AM

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

0
Reply DoomedLung 1/18/2006 12:36:31 PM

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.


0
Reply Richard 1/21/2006 1:02:16 PM

thanks Richard, it works

0
Reply thinktwice 1/25/2006 12:44:51 AM

5 Replies
545 Views

(page loaded in 0.071 seconds)

Similiar Articles:













7/22/2012 5:28:33 AM


Reply: