Solved

WScript.Echo Title

Posted on 2011-03-02
7
2,678 Views
Last Modified: 2012-05-11
I have a bit of Visual Basic script that will echo the current computer name, IP address, and mac address. The only thing is by using the WScript.Echo is displays "Windows Script Host" as the title. I would like to change that title and am unsure if that can be done with WScript.Echo.

Code:

Set objShell = Wscript.CreateObject("Wscript.Shell")
Set colSystemEnvVars = objShell.Environment("System")
Set colUserEnvVars = objShell.Environment("User")
Set objNetwork = Wscript.CreateObject("Wscript.Network")

samUser = objNetwork.UserName
computerName = objNetwork.ComputerName


strComputer = "."
Set objWMIService = GetObject(_
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
    ("Select * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = True")
 
   For Each objItem In colItems
   strIPAddress = Join(objItem.IPAddress, ",")
        WScript.Echo "Computer: " & computerName & vbCr & _
      "IPAddress: " & strIPAddress & vbCr & _
      "MACAddress: " & objItem.MACAddress & vbCr & _
           ""
   Next

I know this is just being a bit picky but i was wondering if there was a way to do it.
Thanks in advance for your responses.
0
Comment
Question by:trineit
7 Comments
 
LVL 12

Expert Comment

by:prashanthd
ID: 35019578
wscript.echo does not have anything to do with the title "Windows Script Host", it is the version using which the script executes.

0
 
LVL 12

Expert Comment

by:prashanthd
ID: 35019598
wscript.echo does not have anything to do with the title "Windows Script Host", it is the version using which the script executes.

0
 
LVL 68

Accepted Solution

by:
Qlemo earned 250 total points
ID: 35019615
No. That popup is a "surrogate" to allow for simple echoing content. You now can
(a) run the script with cscript instead of wscript - that will then echo to the console, not a window.
(b) use a message box, filled yourself (see e.g. http://www.w3schools.com/vbscript/func_msgbox.asp).
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:prashanthd
ID: 35019802
I got confused with the following which is displayed when using cscript, was thinking you were using cscript.

Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Anyway please follow Olemo's suggestions, they are the possible solutions
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 35022491
No points for my comment, just clarifying what has already been said.

WScript.Echo is not configurable.  When a script is run using WScript.exe, it just echos to a plain message box, but if the script is run using CScript.exe, it echoes to the command prompt, and does not wait for any user interaction.

MsgBox is configurable (to some extent).  Whether a script is run using WScript.exe or CScript.exe, it behaves the same way, displaying a windows message box that must have user input to continue.

Qlemo has provided a link to it's syntax, but here's an example:
MsgBox "Your text", vbOKOnly, "Window Title"

Regards,

Rob.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35859678
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now