From LedHed's Wiki
Jump to: navigation, search
 
 
Line 10: Line 10:
 
or
 
or
 
  xcopy \\%hostname%\c$\temp \\computer2\c$\temp
 
  xcopy \\%hostname%\c$\temp \\computer2\c$\temp
 +
 +
 +
 +
OR
 +
 +
 +
You can just use the %ComputerName% environment variable.
 +
 +
''Guess I didn't know that when I originally wrote this article.''
  
 
[[Category:Windows]]
 
[[Category:Windows]]

Latest revision as of 06:32, 18 August 2013

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


OR


You can just use the %ComputerName% environment variable.

Guess I didn't know that when I originally wrote this article.