How to store the hostname in a variable in a .bat file?

Posted by eqbridges on Stack Overflow See other posts from Stack Overflow or by eqbridges
Published on 2009-06-15T21:00:53Z Indexed on 2010/12/29 11:53 UTC
Read the original article Hit count: 155

Filed under:
|
|
|

I would like to convert this /bin/sh syntax into a widely compatible Windows batch script:

host=`hostname`
echo ${host}

How to do this so that it'll work on any Windows Vista, Windows XP, and Windows 2000 machine?

To clarify: I would then like to go on in the program and use the hostname as stored in the variable host. In other words, the larger goal of the program is not to simply echo the hostname.

© Stack Overflow or respective owner

Related posts about Windows

Related posts about scripting