View Full Version : username


Juan
08-23-2005, 07:30 AM
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
--
Juan Bredenkamp

David Candy
08-23-2005, 08:10 AM
xcopy c:\admin "z:\%username%" /y



--
--------------------------------------------------------------------------------------------------
http://webdiary.smh.com.au/archives/_comment/001075.html
=================================================
"Juan" <juanb@blick.co.za> wrote in message news:DB1BC30E-D0AF-42CE-A13D-3D3615428B71@microsoft.com...
> 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
> --
> Juan Bredenkamp

Rod Harrison
09-22-2005, 08:29 PM
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.


"Juan" <juanb@blick.co.za> wrote in message
news:DB1BC30E-D0AF-42CE-A13D-3D3615428B71@microsoft.com...
> 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
> --
> Juan Bredenkamp

Rod Harrison
09-22-2005, 08:33 PM
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.

billious
09-23-2005, 01:37 AM
"Rod Harrison" <rharrison@ubalt.edu> wrote in message
news:%23WiGRy6vFHA.3556@TK2MSFTNGP12.phx.gbl...
> 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

Al Dunbar
09-23-2005, 03:42 AM
"Rod Harrison" <rharrison@ubalt.edu> wrote in message
news:%23WiGRy6vFHA.3556@TK2MSFTNGP12.phx.gbl...
> 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


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