×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

NT Login environment variables

NT Login environment variables

NT Login environment variables

(OP)
I am running NT 4.0 with SP3, with Win95 and Win98 clients.

Our FoxPro programmer recently updated our database to 6.0.

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.

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.
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.

Am I on a wild goose chase here, or am I just NT ignorant? :-) Or both

Thanks in advance.

RE: NT Login environment variables

on nt the system variable is %username% this will give you the username of the user that is logged on.

RE: NT Login environment variables

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.

For Windows 98, I have just verified that the currently logged on userID is stored in the registry. You can find the information at:
HKEY_LOCAL_MACHINE\Network\Logon -- "Username" value

-or-

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control -- "CurrentUser" value

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.

You can use Windows Scripting Host (http://msdn.microsoft.com/scripting) 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++).

Let me know if I could be of any further assistance.



RE: NT Login environment variables

(OP)
Thanks for the replies, guys.

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
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.

Oh well, I think I will try the Windows Scripting Host that sounds like something I can do.

Thanks again for the input.



RE: NT Login environment variables

Windows95 does not have the API to process the account information as NT does when login on. And I assume 98 is the same.

If you don't want to mess with VBscript, C, or JScript, try Kixtart login script. It is a simple scripting language.

I don't have the web address at hand, try search with kixtart keyword.

RE: NT Login environment variables

With nt the vairable are available to login scripts. With Windows 95 clients they aren't immediatly available.
Here is a link to the microsoft supprt site that might be able to help.
http://support.microsoft.com/support/kb/articles/Q162/7/93.asp

RE: NT Login environment variables

With nt the vairable are available to login scripts. With Windows 95 clients they aren't immediatly available.
Here is a link to the microsoft support site that might be able to help.
http://support.microsoft.com/support/kb/articles/Q162/7/93.asp

RE: NT Login environment variables

The command is:

SET USERNAME=%username%

NOT

SET USER=%username%

RE: NT Login environment variables

(OP)
LOL You lost me there.

Why cant you set any environment variable to %username% that that you choose?

If that is the case, then why isnt USERNAME set automatically?

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.

Any other operating system, I would be able to set THEDUDETHATSONNOW as the user name variable if I wanted.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close