Hi,
What is the best way to copy a file without prompting the user?
I have tried
xcopy intro.exe %userprofile%\intro.exe
but the user needs to specify if it's a folder or a file.
Thanks
Copying a file without prompting the user
Moderator: DosItHelp
Re: Copying a file without prompting the user
Code: Select all
echo f|xcopy intro.exe %userprofile%\intro.exe
but could be language settings dependent.And using xcopy for single files is a bad practice. Better use copy:
Code: Select all
copy /y intro.exe %userprofile%\intro.exe
Re: Copying a file without prompting the user
npocmaka_ wrote:using xcopy for single files is a bad practice.
It may seem odd, npocmaka, but I can't see any reason why it would be a bad practice.
I think xcopy uses larger buffers than copy, which could make it more efficient.
Re: Copying a file without prompting the user
hacxx wrote:Hi,
What is the best way to copy a file without prompting the user?
I have tried
xcopy intro.exe %userprofile%\intro.exe
but the user needs to specify if it's a folder or a file.
Thanks
How about just doing this?
Code: Select all
xcopy intro.exe %userprofile% /y
There will be no prompt to bother at all.
Re: Copying a file without prompting the user
Ben Mar wrote:How about just doing this?Code: Select all
xcopy intro.exe %userprofile% /y
There will be no prompt to bother at all.
It needs double quotes to protect against spaces etc, to be robust.
Re: Copying a file without prompting the user
You're right foxidrive. I forgot about the possibility of space(s) in the path.
Thanks
Thanks
Code: Select all
xcopy intro.exe "%userprofile%" /y
Re: Copying a file without prompting the user
Thanks,
I'm using xcopy intro.exe "%userprofile%" /y
I'm using xcopy intro.exe "%userprofile%" /y