Solved

Script to delete and copy Folder

Posted on 2016-08-18
2
38 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 53

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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