Batch file script

Need a batch file script that will copy a file from a network drive and copy it to the individual's desktop.
deer777Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
Should be as simple as:

COPY "\\Server\Share\Folder\Filename.txt" "C:\temp\Filename.txt"

You can do COPY /? at a command prompt to see other options, like overwrite.


»bp
0
Bill PrewIT / Software Engineering ConsultantCommented:
And if you wanted it literally on their Desktop, then:

COPY "\\Server\Share\Folder\Filename.txt" "%USERPROFILE%\Desktop\Filename.txt"


»bp
0
deer777Author Commented:
I need to open the file after copying it as well
how would I do that?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Bill PrewIT / Software Engineering ConsultantCommented:
What kind of file is it?

It may be as simple as either:

COPY "\\Server\Share\Folder\Filename.txt" "%USERPROFILE%\Desktop\Filename.txt"
"%USERPROFILE%\Desktop\Filename.txt"


or

COPY "\\Server\Share\Folder\Filename.txt" "%USERPROFILE%\Desktop\Filename.txt"
START "" "%USERPROFILE%\Desktop\Filename.txt"



»bp
0
Bill PrewIT / Software Engineering ConsultantCommented:
And it you want to tidy it up a bit in the real BAT file then:

@echo off
setlocal

set "FromFile=\\Server\Share\Folder\Filename.txt"
set "ToFile=%USERPROFILE%\Desktop\Filename.txt"

COPY "%FromFile%" "%ToFile%"
START "" "%ToFile%"

Open in new window


»bp
0
deer777Author Commented:
can I put this code behind an icon that I can just click on to run?
0
Bill PrewIT / Software Engineering ConsultantCommented:
You can create a shortcut (LNK) to the file and yes, then you can just click on the shortcut to run it.

The easiest way is once the BAT file exists, in Windows File Explorer, right click on the BAT file, and select Create Shortcut.  That will create a new file in that folder.  You can adjust it's properties (Name, icon, etc), and then after saving those place that file where ever you want it.


»bp
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.