Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for pcname.bat

(view source code of pcname.bat as plain text)

  1. @ECHO OFF
  2. :: Check command line: no parameters needed
  3. IF NOT [%1]==[] GOTO Syntax
  4. :: Check Windows version: 95 and 98 only
  5. VER | FIND "Windows 9" >NUL
  6. IF ERRORLEVEL 1 GOTO Syntax
  7.  
  8. :: Create temporary "answer file" to help store computer name
  9. NBTSTAT -n | FIND "<00>" | FIND "UNIQUE" > TEMP.DAT
  10. ECHO.>>TEMP.DAT
  11. :: Create temporary batch file to help store computer name
  12. TYPE TEMP.DAT | DATE | FIND "UNIQUE" > TEMP.BAT
  13. :: Create empty temporary file to prevent error message
  14. ECHO.>00
  15. :: Create temporary batch file for English Windows 95 and 98
  16. > Enter.bat ECHO SET PCName=%%4
  17. :: Create temporary batch file for Dutch Windows 98
  18. > Typ.bat ECHO SET PCName=%%4
  19. :: Create temporary batch file for Dutch Windows 95
  20. > Voer.bat ECHO SET PCName=%%6
  21. :: Use the temporary batch files to store the computer name in a variable
  22. CALL TEMP.BAT
  23. :: Clean up all temporary files
  24. FOR %%A IN (00 ENTER.BAT TEMP.?AT TYP.BAT UNIQUE VOER.BAT) DO IF EXIST %%A DEL %%A
  25.  
  26. :: Display the result
  27. ECHO ComputerName=%PCName%
  28. :: Done
  29. GOTO End
  30.  
  31. :Syntax
  32. ECHO.
  33. ECHO PCName.bat,  Version 1.00 for Windows 9x
  34. ECHO Store your computer name in an environment variable PCName
  35. ECHO.
  36. ECHO Usage:  PCNAME
  37. ECHO.
  38. ECHO Written by Rob van der Woude
  39. ECHO http://www.robvanderwoude.com
  40.  
  41. :End
  42.  

page last modified: 2024-04-16; loaded in 0.0050 seconds