Question Locked

% wildcard use example

0 helpful
14 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I see this all over , Granted I am still learning and this may seem simple to you guys so dont laugh. I am trying to make user profiles and redirecting folders in those profiles to a local drive so the "profile" wont be so large. What the heck does the % mean before and after the string? //server/share/%username%. I know its a wild card but its meaning eludes me.

14 replies

by cmiller5400

% denotes a variable. %username% is a local variable that gives you the logged in user name. You can see some of them by going to Control Panel, System, Advanced, environment variables.

by xnavydk

Make the folder if I use that variable? if it does exist it will look for it?

by jiminpa

When a string is enclosed by % it tells the system that this is an environmet variable.

Your environment varibles are viewable by right clicking My Computer -> Select Properites -> Click the advanced tab -> then click the environment varibles button.

Edited to insert a missed step.

by xnavydk

Thanks to you both

I really need to go to school for this stuff. Learning to be a network admin on the fly is proving to be quite a handful

by captbilly1eye

Ya left out a step:

Right-click My Computer -> Select Properties -> Click the Advanced Tab -> Then click the Environment Variables button.

I got it and I'll bet the OP got it, but ya never know who may stumble across it down the road.
;-)

BTW... good advice. You deserve a thumb and so does the previous respondent.

by jiminpa

And I modified my post to reflect it. I'm trying to pay attention to a class and answer questions at the same time :)

by xnavydk

my list of variables in win server 03 will be a lot larger than my laptop I hope!

by xnavydk

When I use this variable in the user path the I have the string \\server\share\%username% for this to work, or can I just use the username without the variable % before and after. I should still work right? I really dont want to use the profiles for the purpose they are intended, I just want the system to sync them and back them up. We use a local profile schema non mandatory (except on some field machines)

by jiminpa

Just becareful you are using the correct username under the correct profile.

by xnavydk

Ill try it when I get to the shop. Thanks folks

by dumphrey

example:
net use H: "\\192.168.1.200\Home Folders\%username%\" /persistent:yes

Would map the users home folder from a server to the H drive on their machine, and keep it through reboots.

you can replace %username% with any user name and it will work if the user running the script as permissions to access the share.

another example

cd %homepath%

is the same as
cd c:\Documents and Settings\UserA
or
cd c:\Documents and Settings\%username%

a decent list of them online:

http://vlaurie.com/computers2/Articles/environment.htm

by xnavydk

does this mean that it will be available after logoff?

Thanks a lot, I have learned too much today, I have a headache.. LOL

by ic-it

It will still be available for that user when they logon again. It will not be there for another user.
In this case persistent means that if you ran the script just once, the drive mapping should remain until removed.
Persistent: no would remove the mapping on a restart (unless the script is still there, then it would map it for 1 more use).

This discussion is closed to new replies.