Computing.Net > Forums > Disk Operating System > Using the Computer Name in a Batch Program

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Using the Computer Name in a Batch Program

Reply to Message Icon

Name: Bob Santee
Date: January 22, 2001 at 10:07:00 Pacific
Comment:

I would like to be able to retreive either the computer name or current user name in a batch program using windows 98. I can easily do this in windows 2000.



Sponsored Link
Ads by Google

Response Number 1
Name: just-.-me
Date: January 22, 2001 at 18:31:08 Pacific
Reply:

Use the Net command.

'net config /yes'

the output of this command is similar

Computer Name
User Name
Workgroup
Workstation Root Dir

Software Version
Redirector Version



0

Response Number 2
Name: just-.-me
Date: January 22, 2001 at 18:34:39 Pacific
Reply:

I forgot to mention, to make this info useable in a batch file you might want to dump it into a txt file. Then use your favorite language to parse the file. I would then set all of the variables into the environment. Use them from there.


0

Response Number 3
Name: Laurence
Date: January 24, 2001 at 13:07:21 Pacific
Reply:

: CompName2.bat - Gets 'computername' in Win 95/98
:: Tom Lavedas
@echo off
if '%1=='2nd goto 2nd
echo %0 2nd %%1 > computername.bat
set key=System\CurrentControlSet\Control\ComputerName\ComputerName
start /w regedit /e ~tmp.txt HKEY_LOCAL_MACHINE\%key%
find "=" ~tmp.bat
~tmp.bat
:2nd
for %%v in (Computername.bat ~tmp.??t) do del %%v
for %%v in (%2) do set ComputerName=%%v
Echo % For example, %Computer Name: %ComputerName%

Batfiles: The DOS batch file programming handbook



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Using the Computer Name in a Batch Program

Win 98 computer name as a varable www.computing.net/answers/dos/win-98-computer-name-as-a-varable/14271.html

Rename in a Batch file www.computing.net/answers/dos/rename-in-a-batch-file/12873.html

want specify enter in a batch file www.computing.net/answers/dos/want-specify-enter-in-a-batch-file/14558.html