username

G

Guest

Hi can some one please help

I am using a xcopy command as follow

xcopy c:\admin z:\%username% /y

this is not the probleme but i have a user that is juanb but then it saves
his stuff under his username juanb but the probleme is i have his name under
the z: as Juan Bredenkamp now is there a way i can do this by entering maby
%firstename% & %lastname% or %fullusername% maybe

there is to many users that i have to change on our z:\ if i whant to use
there usernames as the directory

i would rather use there full names that the "AD" has it is just a matter of
reading it out

example xcopy c:\admin z:\%fullname% /y

please help
 
R

Rod Harrison

This is a batch script that will calculate the first and last name and place
them into variables that you can then use.
See my example below.

********************************************
@echo off
for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if /i
"%%a"=="Full" if /i "%%b"=="Name" set fnme=%%c
for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if /i
"%%a"=="Full" if /i "%%b"=="Name" if /i "%%c"=="%fnme%" set lnme=%%d
echo %fnme% %lnme%
********************************************

I basically figure out the first name and last name from AD and place those
results into variables %fnme% and %lnme%
You could use these variables to do what you are requesting.
 
R

Rod Harrison

Be careful, my previous post word wrapped. I am resending this to notate
where each line starts

********************************************
Line 1- @echo off
Line 2- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" set fnme=%%c
Line 3- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" if /i "%%c"=="%fnme%" set lnme=%%d
Line 4- echo %fnme% %lnme%
********************************************

I basically figure out the first name and last name from AD and place those
results into variables %fnme% and %lnme%
You could use these variables to do what you are requesting.
 
B

billious

in message
Be careful, my previous post word wrapped. I am resending this to notate
where each line starts

********************************************
Line 1- @echo off
Line 2- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" set fnme=%%c
Line 3- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" if /i "%%c"=="%fnme%" set lnme=%%d
Line 4- echo %fnme% %lnme%
********************************************

I basically figure out the first name and last name from AD and place
those
results into variables %fnme% and %lnme%
You could use these variables to do what you are requesting.

or to simplify,
********************************************
Line 1- @echo off
Line 2- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" set fnme=%%c&set lnme=%%d
Line 3- echo %fnme% %lnme%
********************************************

Note that in NT/2K/XP (ie NT+) "&" can be used to separate commands on a
line

- and possibly for entertainment,
********************************************
Line 1- @echo off
Line 2- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a%%b"=="FullName" set fnme=%%c&set lnme=%%d
Line 3- echo %fnme% %lnme%
********************************************

HTH

....Bill
 
A

Al Dunbar

in message
Be careful, my previous post word wrapped. I am resending this to notate
where each line starts

********************************************
Line 1- @echo off
Line 2- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" set fnme=%%c
Line 3- for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if
/i "%%a"=="Full" if /i "%%b"=="Name" if /i "%%c"=="%fnme%" set lnme=%%d
Line 4- echo %fnme% %lnme%
********************************************

Another common (and simpler) way to annotate linewrap is to prefix each line
with whitespace, i.e.:

********************************************
@echo off
for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if /i
"%%a"=="Full" if /i "%%b"=="Name" set fnme=%%c
for /f "Tokens=1-4" %%a in ('net user "%username%" /domain') do if /i
"%%a"=="Full" if /i "%%b"=="Name" if /i "%%c"=="%fnme%" set lnme=%%d
echo %fnme% %lnme%
********************************************

/Al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top