Get Computer Name

@echo off
:: Parses the output of the “net config” command to get
:: the computer name. Uses debug to trim
:: away all unwanted info from the response line.
set value=
:: Use net config to get lots of data, then filter it
net config | find “Computer name” > setvalue.bat
:: Use DEBUG to overwrite the beginning data
> script echo e 0100 ” set value=”
>> script echo w
>> script echo q
debug setvalue.bat nul
del script
call setvalue.bat
del setvalue.bat
echo Computer name is %value%

:: Miles Fenton in the UK pointed out that while
:: “net config” works under Win9x, you’ll need to
:: use “net config server” or
:: “net config workstation” when running under NT.

Follow

Get every new post delivered to your Inbox.