By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

how to display a message in console window?

P: n/a
<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
Share this Question
Share on Google+
5 Replies


P: n/a
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

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

Jan 18 '06 #3

P: n/a
I'm kinda intermediate with Javascript, what is this type of syntax
referencing to?

Jan 18 '06 #4

P: n/a
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

P: n/a
thanks Richard, it works

Jan 25 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.