Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NT Login environment variables 1

Status
Not open for further replies.
Jul 22, 1999
11
I am running NT 4.0 with SP3, with Win95 and Win98 clients.<br>
<br>
Our FoxPro programmer recently updated our database to 6.0. <br>
<br>
When FoxPro starts on a workstation it asks for user name and password. We don't want to make the users type in their username every time, just the password, so the programmer added a routine that reads the USER environment variable, since he is more used to working on Netware networks.<br>
<br>
I was trying to set up a login script that would set the USER environment variable to whatever the user logged in as. With seemingly no success. i am kinda new to NT myself so I am pretty well stuck right now on that issue.<br>
I tried to add a SET USER=%user name% to the login script but that didnt seem to work. I tried SETX as well. I also tried adding it in the Control Panel/System/Environment deal, but that didnt work either. <br>
<br>
Am I on a wild goose chase here, or am I just NT ignorant? :) Or both<br>
<br>
Thanks in advance.<br>

 
on nt the system variable is %username% this will give you the username of the user that is logged on.
 
For environment variables on Windows systems, you can run: "set" or "set ¦ more" at a command prompt to get a listing of all the available environment variables. However, be warned that this also includes the user specific environment variables for NT platforms. <br>
<br>
For Windows 98, I have just verified that the currently logged on userID is stored in the registry. You can find the information at:<br>
HKEY_LOCAL_MACHINE\Network\Logon -- "Username" value<br>
<br>
-or-<br>
<br>
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control -- "CurrentUser" value<br>
<br>
I don't have a Windows '95 box to checkout, but I'd imagine the two OS's are close enough that the same would apply.<br>
<br>
You can use Windows Scripting Host ( to run a VBScript that will access the registry and set an environment variable. Then again, you could just go after the registry entries under program code (like Visual Basic or Visual C++).<br>
<br>
Let me know if I could be of any further assistance.<br>
<br>
<br>
<br>
 
Thanks for the replies, guys.<br>
<br>
Okay so %username% is the NT variable. I believe I tried it that way. I created a login script for each user that does SET USER=%username% and I also tried it with <br>
SET USER=%user name%, because the NT book that I have shows it both ways. LOL. and then when I logged on to the domain through a Win 98 box and went to DOS and typed SET it did not list USER as a variable. <br>
<br>
Oh well, I think I will try the Windows Scripting Host that sounds like something I can do. <br>
<br>
Thanks again for the input.<br>
<br>
<br>
<br>

 
Windows95 does not have the API to process the account information as NT does when login on. And I assume 98 is the same.<br>
<br>
If you don't want to mess with VBscript, C, or JScript, try Kixtart login script. It is a simple scripting language.<br>
<br>
I don't have the web address at hand, try search with kixtart keyword.
 
The command is:<br>
<br>
SET USERNAME=%username%<br>
<br>
NOT<br>
<br>
SET USER=%username%
 
LOL You lost me there.<br>
<br>
Why cant you set any environment variable to %username% that that you choose?<br>
<br>
If that is the case, then why isnt USERNAME set automatically?<br>
<br>
I will try that to see what happens, although it will not help me any since the software is written to read USER and not USERNAME. If it turns out that that is the case, then I will be convinced like all of the others that Microsoft is retarted. LOL. <br>
<br>
Any other operating system, I would be able to set THEDUDETHATSONNOW as the user name variable if I wanted.<br>
<br>
<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top