Page 1 of 1

get computername

PostPosted: Fri Aug 07, 2009 1:34 pm
by dpayer
I needed to include the machine name in a batch file I was creating via NB.

In batch scripts you can get the computer name of the machine running your application by using the batch variable


I didn't see a NB function for this so I found a simple VB script to do this and I thought I'd share it in case it would be useful to anyone else.

Create a function and enter this as its content:

Code: Select all
set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
publication.nbSetVar "[thecomputername]", sComputername

Call the function by whatever name you gave it and the variable [thecomputername] will hold the name of your machine.

This same method can be used to gather almost any kind information about your machine and its configurations. Google is your friend to see how others have created VB / wscript / scripts to get this kind of info.

PostPosted: Mon Aug 17, 2009 2:59 pm
by cp4w
Thank you very much for your function.