Solved

WScript.Echo Title

Posted on 2011-03-02
7
2,752 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 69

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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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