Solved

Script to delete and copy Folder

Posted on 2016-08-18
2
24 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 51

Accepted Solution

by:
Bill Prew earned 500 total points (awarded by participants)
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Do you have users whose passwords are expiring and they are constantly calling you?  Well I sure did and needed a way to put an end to this.  We have a lot of remote users which would not be notified that their passwords were expiring since they wer…
Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
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…

743 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

13 Experts available now in Live!

Get 1:1 Help Now