How to read computer name and compare it?

  • Thread starter Thread starter Matt Solob
  • Start date Start date
M

Matt Solob

I want to read the name of the local computer and do something depending from
the result. In other words I want to do something like this:

find "mycom234" %SYSTEMVARIABLEWHICHCONTAINSCOMPNAME% >nul
if %errorlevel%==0 (
Echo I am on a computer whose name contains "mycom234"
) else (
Echo I am on a computer whose name contains NOT "mycom234")


However which system variable contains the computer name?

How do I do this otherwise?

Matt
 
Matt Solob said:
I want to read the name of the local computer and do something depending
from
the result. In other words I want to do something like this:

find "mycom234" %SYSTEMVARIABLEWHICHCONTAINSCOMPNAME% >nul
if %errorlevel%==0 (
Echo I am on a computer whose name contains "mycom234"
) else (
Echo I am on a computer whose name contains NOT "mycom234")


However which system variable contains the computer name?

How do I do this otherwise?

Matt

There is a very easy method to find out for yourself, one that hardly
justifies your extensive cross-posts:

1. Open a Command Prompt (Start / Run / cmd{OK}
2. Type this command:
set {Enter}

You will see all environmental variables, including the one containing your
computer's name.
 
Back
Top