Solved

WScript.Echo Title

Posted on 2011-03-02
7
2,629 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

16 Experts available now in Live!

Get 1:1 Help Now