Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
December 18, 2006
The full DNS name my workstation is JSI009.JSIINC.COM and it's Common Name is JSI009.
Using standard commands, I have scripted FullDNSName.bat to retrieve the full DNS name of the current computer.
The syntax for using FullDNSName.bat is:
[call] FullDNSName Name
Where Name is a call directed environment variable that will contain the computer's full DNS name.
FullDNSName.bat contains:
@echo offif {%1}=={} @echo Syntax: FullDNSName Name&goto :EOFif exist "%TEMP%FullDNSName.vbs" goto [email protected] objSysInfo = CreateObject("ADSystemInfo") >"%TEMP%FullDNSName.vbs"@echo.strComputerDN = objSysInfo.ComputerName>>"%TEMP%FullDNSName.vbs"@echo.Set objComputer = GetObject("LDAP://" ^& strComputerDN)>>"%TEMP%FullDNSName.vbs"@echo.Wscript.Echo objComputer.dnsHostName>>"%TEMP%FullDNSName.vbs":doitset %1=Not Foundfor /f "Tokens=*" %%a in ('cscript //nologo "%TEMP%FullDNSName.vbs"') do ( set %1=%%a)
You May Also Like