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?
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 PrewCommented:
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 PrewCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Bill PrewCommented:
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 PrewCommented:
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 PrewCommented:
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 ConnectWise

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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.