@ECHO OFF
REM Stores computername, user ID and Workgroup in environment
REM variables COMPUTERNAME, USERNAME and WORKGROUP in Windows
REM Uses WINSET, which must be located somewhere in the PATH.

NET CONFIG | FIND /I "Computer name" > %TEMP%.\NETCONF$.BAT
ECHO > COMPUTER.BAT WINSET COMPUTERNAME=%%2
CALL %TEMP%.\NETCONF$.BAT

NET CONFIG | FIND /I "User name" > %TEMP%.\NETCONF$.BAT
ECHO > USER.BAT WINSET USERNAME=%%2
CALL %TEMP%.\NETCONF$.BAT

NET CONFIG | FIND /I "Workgroup" > %TEMP%.\NETCONF$.BAT
ECHO > WORKGROUP.BAT WINSET WORKGROUP=%%1
CALL %TEMP%.\NETCONF$.BAT

DEL USER.BAT
DEL COMPUTER.BAT
DEL WORKGROUP.BAT
DEL %TEMP%.\NETCONF$.BAT
Published in: Batch
Download

Related snippets