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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File syntax wrong 2

Status
Not open for further replies.

Jimuniguy

Technical User
Mar 6, 2002
363
GB
Hello,

Whats wrong with this syntax and what should it be please?

Code:
COPY C:\runonce\runonce.bat C:\Documents and Settings\%username%\runonce.bat

Something is not correct, the %username% is in there because I need it to copy itself to the username folder of the documents and settings

Jim
 
It should be ...

COPY C:\runonce\runonce.bat "C:\Documents and Settings\%username%"

You need quotes around the destination, and you don't put in the name of the file in the destination, just the location. Meaning, you don't need to put "runonce.bat" after %username%
 
Let me rephrase the first thing I said there...

"It should be ..." needs to be replaced by "You can use..."
There's always more than one way to skin a cat. Happy batching!
 
%USERPROFILE% expands, without issue, and without a dedicated drive reference, to exactly what the original poster requested.

I am baffled by your correction to my post.

 
I am not correcting your post. That's why I wrote the second post to say "You can use..." and "... more than one way...".
 
mpnut:

Thanks,
I was confused as I thought at first that your notion was that the variable expansion would fail, and a fully pathed alternative was necessary.

I appreciate your note.
And your excellent answer to the thread starter.

Best,
Bill Castner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top