Solved

Script to delete and copy Folder

Posted on 2016-08-18
2
47 Views
Last Modified: 2016-09-08
HI All,

Know this is a simple request looked online didn't see a direct answer, tried xcopy and robocopy, didnt work. Need a startup script to run and delete a folder and contents on users local machine and then copy a folder and contents from a network location.

Thanks.
0
Comment
Question by:jaya31
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 56

Accepted Solution

by:
Bill Prew earned 500 total points (awarded by participants)
ID: 41761521
You might have to tweak this a bit, but here is the basic shell.

sRemoveDir = "c:\dir1"
sCopyDir = "\\sharename\dir3"
sDestDir = "c:\dir2"

Set oFSO = CreateObject("Scripting.FileSystemObject")

If oFSO.FolderExists(sRemoveDir) Then
   oFSO.DeleteFolder sRemoveDir
End If

If oFSO.FolderExists(sCopyDir) Then
   oFSO.CopyFolder sCopyDir, sDestDir
End If

Open in new window

~bp
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question