Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining the server name

Status
Not open for further replies.

collierd

MIS
Dec 19, 2001
509
DE
Hello

Is there a way of obtaining the server name with vbsript
In much the same way as you would use @@SERVERNAME in SQL
I need it just to tag it onto an e-mail

Thanks

Damian
 
Wich server name do you want ?
http server, mail server, ... ???
Be more clear about your architecture. Water is not bad as long as it stays out human body ;-)
 
The http server
Basically it is the server I am operating on
I want to create a piece of vbsript that I can put on a number of servers and have this e-mail the free space at 7am for analysis
This e-mail should contain the relevant server being interogated
I can do everything bar obtaining the local server name to append to the message
Hope that explains it

Damian.
 
If you run your script locally on each server, you can obtain computer name by reading this registry key : "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\ComputerName\ComputerName".
Note : use "WshShell.RegRead" method to read registry.
Water is not bad as long as it stays out human body ;-)
 
Stand alone
Just want to be able to reference script via a scheduled task
 
To retrieve the Hostname of the local PC, use the ComputerName property of the Network object.

Set oNetwork = CreateObject("WScript.Network")
WScript.Echo oNetwork.ComputerName

FWIW, if your servers or Win2k or later, you may want to explore using WMI to achieve your tasks remotely, ISO, having to drop this process on each server.

Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top