Operating Systems :: DOS :: how to get pcs name in dos??? |
|||
| By: progGoon |
Date: 31/01/2003 00:00:00 |
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 | Type : Comment |
|
| no possible i think, unless you write a code for this |
|||
| By: pbarrette | Date: 31/01/2003 15:32:00 | 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 | 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 | 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 | 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 | 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 | 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 | Type : Comment |
|
| madlan@ntlworld.com |
|||
| By: VGR | Date: 01/02/2003 08:05:00 | Type : Comment |
|
| gone |
|||
| By: sumotimor | Date: 01/02/2003 19:30:00 | 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 | 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 | 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 | 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 | 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 |
|||
©2012 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








