Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what am i doing wrong newbie to batch files

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
0
0
GB
hi

i am doing this

for /f "tokens=3 delims=\" %%i in ("%USERPROFILE%") DO (set user=%%i)

COPY C:\Documents and Settings\%userprofile%\Application Data\Microsoft\AddIns\PERSONAL.xla C:\Documents and Settings\%userprofile%\Desktop\personal.xla

and it doesnt work.
and I dont know why anybody help.

hopefully you can see what i am trying to do.

Hope this is of use, Rob.[yoda]
 
and it doesnt work."

What doesn't work?
What does it do that it should not do?
What does it not do that it should do?
Is there any output?


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
it does nothing,

I want to be able to copy the personal.xla from the active profile to another location on the computer

Hope this is of use, Rob.[yoda]
 
Try this change:

COPY C:\Documents and Settings\%[red]user[/red]%\Application Data\Microsoft\AddIns\PERSONAL.xla C:\Documents and Settings\%userprofile%\Desktop\personal.xla

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Oops, sorry, you have to change it both places:

COPY C:\Documents and Settings\%[red]user[/red]%\Application Data\Microsoft\AddIns\PERSONAL.xla C:\Documents and Settings\%[red]user[/red]%\Desktop\personal.xla


Although I have to wonder, why use the complete string at all? %Userprofile% returns the string so this:

C:\Documents and Settings\%[red]user[/red]%\Application Data\Microsoft\AddIns\PERSONAL.xla

Is the same thing as this:

%Userprofile%\Application Data\Microsoft\AddIns\PERSONAL.xla


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
two things... 1) EBGreen is right, %userprofile% will put in the path you need... to test if that is the path you want get to a dos promt (start>run>cmd) then type set
this will show you a list of defined variables... userprofile should be one of them...

2) im pretty sure you your going to use a path in which there is a space in it (ie: \Documents and Settings\) you will need to put the path in quotes. in other words:
"C:\Documents and Settings\%user%\Application Data\Microsoft\AddIns\PERSONAL.xla"

these two things should get you going. a great rescource for dos is:
invaluable.
hope this helps.
ccastelein
 
hi,

ccastelein you were correct, i had figured out, and now user userprofile with Quotes and it works fine.

thansk for the input

Hope this is of use, Rob.[yoda]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top