469,352 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

how to display a message in console window?

<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

Jan 18 '06 #1
5 18310
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.
Jan 18 '06 #2
i call it in bat file,
like this :
cmd CScript /k C:\test.wsf

Jan 18 '06 #3
I'm kinda intermediate with Javascript, what is this type of syntax
referencing to?

Jan 18 '06 #4
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.
Jan 21 '06 #5
thanks Richard, it works

Jan 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jason Callas | last post: by
5 posts views Thread by phickman | last post: by
11 posts views Thread by objectref | last post: by
reply views Thread by Mythran | last post: by
10 posts views Thread by Stephany Young | last post: by
3 posts views Thread by =?Utf-8?B?VGVycmFuY2U=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.