Discussion Locked

% syntax and usage

0 helpful
11 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am a network engineer/administrator. I set up domains and workstations. Lately I have been useing %username% and with some of my login situations. There is also %systemroot%. My question is what is "%" exactly, how does it work when you enclose aword with it, and what is all the various words it can be used with. I have 4 domain controlers and I would also like to maybe use this from a workstation to find out which domain controller authinicated me. Thanks.

11 replies

by mckaytech

The %whatever% syntax is used to pull environment variables into a batch file and then use them somehow. So it's simply a substitution mechanism that allows a batch file to behave differently depending on the environment variables on that machine.
To see what various words it can be used with, just go to a command prompt and type "set" and hit enter. The list that will appear shows the current environment variables and their contents.

For instance, the logon server is called just that and you could display that with the statement "echo I was authenticated by %logonserver%" and on your display, you would see "I was authenticated by \\ntpdc01".

paul

by eltonsipes

Great answer. You really told me what I wanted to know. Your answer is exactly what I was looking for, so I can set up my login script so that the user can see which server authenticated them. I feel this will help me determine if my BDCs are all share the load, and other nice to know info. Thanks alot.

by robshan

I assume you are talking batch files. %WORD% will subsitute the value of the environment variable word. eg
Echo %COMPUTERNAME% will execute as Echo WORKSTATION09

Some useful ones
LOGONSERVER - The server that validated the logon
USERNAME - Username
USERDOMAIN - User's Domain
USERPROFILE - Location of profile directory

Type SET at the command line for a full list.

by eltonsipes

Pretty good info, I wish I could find out all the veriables, the SET command gives more info than I need but doesn't give me a list of all the %veriables%.

by mike

You want login script POWER!! use the KIX script processor on the Resource kit, it is a mix of Basic/C commands and gives you AWESOME flexibility, ie: adding registry entreis, gui response boxes, errorlevel returns if member of group etc, and MUCH MUCH MORE. Very few org's use this program, but it is EXTREAMLY Powerfull!!!
Good Skill
Mike

by eltonsipes

Look like this guy had problems reading my question also or he/she just doesn't know. Thanks anyway.

by eltonsipes

Look like this guy had problems reading my question also or he/she just doesn't know. Thanks anyway.

This discussion is closed to new replies.