Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

How do I copy all of the files from a mapped network drive's shared folder to the local c: drive?

Hello
I need a script to copy files from a network share (drive is already mapped) to the local c: drive of many pc's.  
I am thinking of something like this.  Beware, as I am a newbie at this:

@echo off
cls
if exist x:\ net use x: /delete
net use x: \\server1\share
copy x:\*.* \\%computername%\c:
x:
start file.exe
::  file.exe is one of the files that was copied over from the \\server1\share
exit

Thanks!
0
cliffordgormley
Asked:
cliffordgormley
  • 3
  • 2
2 Solutions
 
MidnightOneCommented:
cliffordgormley:

What's the goal of this script, precisely?

Is this a one-shot copy or something that will be happening more-or-less daily?

MidnightOne
0
 
inbarasanCommented:
If you are going to use this script regularly then you may use xcopy with overwrite option so that it doesn't promopt whether you want to overwrite it or not(This is dangerous also)

Even otherwise xcopy is good.
To know more about xcopy refer : http://www.ss64.com/nt/xcopy.html
0
 
cliffordgormleyAuthor Commented:
it is actually going to be a one time copy.  If the script has been run before, I will not need to copy the files over from the server share to the local machine.
I am going to use an IF-THEN statement to check if the script was run before. Those details are not really required, are they?
Thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
MidnightOneCommented:
Script should read, then

@echo off
if exist c:\file.exe GOTO END
xcopy %logonserver%\netlogon\FOLDER c:\*.*
start c:\file.exe
:END
exit

Caveats:
 All files are in FOLDER within the NETLOGON share
 aCopiedFile is one of the files in the group you're copying
 You're using a GPO and setting this as a logon script

HTH

MidnightOne
0
 
cliffordgormleyAuthor Commented:
Hello Midnight.
Looks good, but do the files have to be in the NETLOGON share?  I have already mapped a drive to a folder on the remote server where the files are, and have given the user both Share and NTFS permissions to READ (copy) from that share.  I can post the current script here if you like.
Thanks

BTW, is XCOPY used instead of COPY because it will automatically overwrite any existing files??
0
 
MidnightOneCommented:
cliffordgormley:

Doesn't have to be in the netlogon share. Personally, I find it easier because all my scripts then look the same.

HAND

MidnightOne
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now