JSI Tip 1786. Another way to set %UserName%, %ComputerName%, and %LogonServer% for W9x.
Jerold Schulman
November 8, 1999
2 Min Read
In tip 0120, the %UserName%, %ComputerName%, and %LogonServer% variables could be retrieved by Kixtart and set into W9x by WINSET.
You can use PUTINENV.EXE to retrieve these environment variables and WINSET.EXE, from the W9x CD-ROM, to set them into the Windows environment.
If you type PUTINENV.EXE /? at a CMD prompt, you receive:
PUTINENV 2.13 by MJ Winkler, Apr 7 1993, 13:32:00.PUTINENV is a batch file enhancer that puts or modifies variables inDOS' Environment. You may then access these variables from a batchfile. See your DOS manual for details.Syntax is: PUTINENV command [argument(s)] [/U | /L | /P] [/M] Where: command = the PUTINENV command (see list below). argument(s) = the argument(s), if any, to the PUTINENV command. /U = Make returned environment strings uppercase. /L = Make returned environment strings lowercase. /P = Preserve case (default). /M = Edit the "master environment". The Master Environment is the one owned by the first command processor. /O:appname = Edit another application's environment.ErrorLevel will be set >= 1 if there is an error.Cmd Arguments Description and variable(s) created.--- ----------------------- -------------------------------------------------- ? Displays this help information. A network_name or '*' Determine the "burned in address" of the adapter that the network_name is defined on. STRING=12 hex-digit address C Determines the current machine/computer name. STRING=computer name D device Determines the server name and share name assigned to a redirected device. SERVER=server name (no '\') SHARE=share name (no '') E [+ | -]directory; Edit the PATH variable. Use '+' to insert a directory, '-' to remove one. Separate directories with a ';'. You may also list multiple directories at one time (i.e +C:123;-C:WP51;). F filespec Splits a filespec into its component parts. DRIVE=drive letter (no ':') DIR=directory(s) (no ending '') FNAME=file name EXT=file extension (no '.') L Supplies following info on LAN Manager: ROOT=location of LANMAN directory COMPUTERNAME=computer name USERNAME=user name LANGROUP=lan group or default_domain LOGONSERVER=logon server MAJOR=major version number MINOR=minor version number N Determines the current network/NetBIOS/User name. STRING=user name P prompt length [default] Prompts for input of specified length and returns the default if nothing is entered. STRING=string entered or default Q prompt length [default] Just like P but echos *'s instead of the actual characters--great for passwords. R Report status of the environment. S string start length Extracts a substring. STRING=requested portion of string T 12 or 24 Time (12 or 24 hour format) and Date. If 12 hour format is selected, 'a' or 'p' will be appended to TIME. TIME=hh:mm:ss DATE=mm/dd/yy V DOS version. MAJOR=major version number MINOR=minor version number Z variable=string Mimick the DOS SET command with the exception that the variable-name case is preserved. variable=string
Thus, you can use the following, or similar, snipit in your logon script:
if "%OS%"=="Windows_NT" goto winnt
if exist %windir%putinenv.exe goto nth
copy %0..putinenv.exe %windir%
:nth
%windir%putinenv.exe L
%LogonServer%NetLogonWinset USERNAME=%USERNAME%
%LogonServer%NetLogonWinset COMPUTERNAME=%COMPUTERNAME%
%LogonServer%NetLogonWinset LOGONSERVER=%LOGONSERVER%
:winnt
About the Author
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
You May Also Like