(view source code of pcname.bat as plain text)
@ECHO OFF
:: Check command line: no parameters needed
IF NOT [%1]==[] GOTO Syntax
:: Check Windows version: 95 and 98 only
VER | FIND "Windows 9" >NUL
IF ERRORLEVEL 1 GOTO Syntax
:: Create temporary "answer file" to help store computer name
NBTSTAT -n | FIND "<00>" | FIND "UNIQUE" > TEMP.DAT
ECHO.>>TEMP.DAT
:: Create temporary batch file to help store computer name
TYPE TEMP.DAT | DATE | FIND "UNIQUE" > TEMP.BAT
:: Create empty temporary file to prevent error message
ECHO.>00
:: Create temporary batch file for English Windows 95 and 98
> Enter.bat ECHO SET PCName=%%4
:: Create temporary batch file for Dutch Windows 98
> Typ.bat ECHO SET PCName=%%4
:: Create temporary batch file for Dutch Windows 95
> Voer.bat ECHO SET PCName=%%6
:: Use the temporary batch files to store the computer name in a variable
CALL TEMP.BAT
:: Clean up all temporary files
FOR %%A IN (00 ENTER.BAT TEMP.?AT TYP.BAT UNIQUE VOER.BAT) DO IF EXIST %%A DEL %%A
:: Display the result
ECHO ComputerName=%PCName%
:: Done
GOTO End
:Syntax
ECHO.
ECHO PCName.bat, Version 1.00 for Windows 9x
ECHO Store your computer name in an environment variable PCName
ECHO.
ECHO Usage: PCNAME
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
page last modified: 2024-04-16; loaded in 0.0050 seconds