visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
316 experts, 1194 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Operating Systems :: DOS :: how to get pcs name in dos???


By: progGoon U.S.A.  Date: 31/01/2003 00:00:00  English  Points: 25 Status: Answered
Quality : Excellent
How do i get the name of a pc in dos?

Its for a batch file:

echo %pcname% > pcname.txt
By: TheFalklands Date: 31/01/2003 15:17:00 English  Type : Comment
no possible i think, unless you write a code for this
By: pbarrette Date: 31/01/2003 15:32:00 English  Type : Comment
Hi progGoon,

This ain't pretty, but it works. I assume from your last question that you are looking for the netbios name on Win9x.

:: -------GETNAME.BAT----------
@echo off
set pcname=
echo. > 00
nbtstat -n|find "<00> UNIQUE">set.dat
echo. >>set.dat
date <set.dat | find "<00>">setit.bat
ECHO SET PCNAME=%%4>ENTER.BAT
call setit.bat
del 00
del set.dat
del setit.bat
del enter.bat
del unique
ECHO %PCNAME%
:: -------GETNAME.BAT----------

pb

By: pbarrette Date: 31/01/2003 17:14:00 English  Type : Comment
Hi again,

This one does the same thing, but is a lot less complicated. It returns the computer name as "\\PCNAME" rather than "PCNAME"

:: -------GETNAME.BAT----------
@ECHO OFF
NET CONFIG|FIND "Computer Name">~GETIT.BAT
ECHO SET PCNAME=%2>COMPUTER.BAT
CALL COMPUTER.BAT
DEL GETIT.BAT
DEL COMPUTER.BAT
ECHO %PCNAME%
:: -------GETNAME.BAT----------

pb

(Why didn't I think of this earlier?)
By: VGR Date: 01/02/2003 07:13:00 English  Type : Answer
yes. I can write a small "DOS" program for you getting this from the registry, if you want.
By: progGoon Date: 01/02/2003 07:39:00 English  Type : Comment
Pbarrette, your batch file doesnt seen to find the name, just outputs echo is OFF.

(i tested it on XP could that be why?)

VGR

Yes please!
By: VGR Date: 01/02/2003 07:53:00 English  Type : Comment
Done.
Where do you want it ? upload to a web server, by email, by yahoo messenger ?
By: pbarrette Date: 01/02/2003 07:55:00 English  Type : Comment
Hi progGoon,

It's because you tested it on XP. If you run it on Win9x, it will work flawlessly.

pb
By: progGoon Date: 01/02/2003 08:01:00 English  Type : Comment
madlan@ntlworld.com
By: VGR Date: 01/02/2003 08:05:00 English  Type : Comment
gone
By: sumotimor Date: 01/02/2003 19:30:00 English  Type : Comment
Windows NT based operating systems (NT, 2000, XP) have a system variable called "computername" - you can access this by entering:

... %computername% ...

where ... are commands preceding or following the computername.

For example, if you want to save a computer's IP configuration you could say:

ipconfig /all > %computername%.txt

(mind you, this will create a file ".txt" if run on win9x/me, but on NT Based os', if the computer name was "mypc" then the file created would be "mypc.txt")
By: TheFalklands Date: 09/02/2003 23:02:00 English  Type : Comment
Sumotimor has got the right idea.

Don't know about 95/98/ME but type in:

echo %computername% > %computername%.txt

eg. my computer name is powder. If i execute the above at a prompt I will get a file called powder.txt and within that file will be the word powder.
By: VGR Date: 09/02/2003 23:22:00 English  Type : Comment
this question should be closed ASAP, all answers have been submitted since long. And my programschen sent ;-)
By: pbarrette Date: 09/02/2003 23:48:00 English  Type : Comment
Hi TFL,

Both you and sumotimor are correct about the %COMPUTERNAME% variable in NT/2K/XP, but I was making the assumption that Chinswain was looking for a solution to be used on Win98.
Always glad to be of service,
pb
By: VGR Date: 10/02/2003 00:45:00 English  Type : Comment
hello,
I want to share the points with the answer with the echo %computername%

is this possible ? Thanks

Do register to be able to answer

EContact
browser fav
page generated in 424.869060 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page