From LedHed's Wiki
Revision as of 19:06, 5 January 2007 by Ledhed (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to set the hostname environment variable from a batch file.

for /f %%x in ('hostname.exe') do set hostname=%%x

Note: when running from the command line you only need 1 percent sign in front of the x.

for /f %x in ('hostname.exe') do set hostname=%x

Usage:

echo %hostname%

or

xcopy \\%hostname%\c$\temp \\computer2\c$\temp