Host name via batch file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dostips12
Posts: 5
Joined: 29 Sep 2011 04:03

Host name via batch file

#1 Post by dostips12 » 29 Sep 2011 04:17

Hi everybody

How can make host name via batch file
so if the ip address change i can go to my computer by using that host name address with out knowing the ip address

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Host name via batch file

#2 Post by alleypuppy » 29 Sep 2011 10:05

I know this works on Windows XP. If you are using Windows Vista/7 andd it doesn't work, post a reply and I'll fix it.

Code: Select all

for /f "tokens=16" %%a in ('ipconfig /all ^| find "Host Name"') do set HOSTNAME=%%a

dostips12
Posts: 5
Joined: 29 Sep 2011 04:03

Re: Host name via batch file

#3 Post by dostips12 » 29 Sep 2011 13:18

Thank you alleypuppy
now if i want to use remote desktop
can i use this host name without knowing ip address????
what if there is some one have same host name??

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Host name via batch file

#4 Post by alleypuppy » 29 Sep 2011 15:31

Do you mean use the host name instead of the IP Address to connect to a computer? You can use the hist name instead of the IP Address.

And two computers cannot have the same host name on the same network.

dostips12
Posts: 5
Joined: 29 Sep 2011 04:03

Re: Host name via batch file

#5 Post by dostips12 » 29 Sep 2011 15:45

what is hist name??
and the connect between 2 computer not in same network but via enternet the first computer in work and the other in home.

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Host name via batch file

#6 Post by alleypuppy » 29 Sep 2011 21:12

Oops! Sorry, I meant host name, not hist name.

And since the two computers aren't on the same network, you cannot use the host name because the host name is used in LAN environments only.

If you want to connect to your work computer from home, just use LogMeIn (http://www.logmein.com). It's basically Remote Desktop for computers on different networks.

Post Reply