Solved

Script to delete and copy Folder

Posted on 2016-08-18
2
30 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
2 Comments
 
LVL 52

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
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 tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now