Solved

Script to delete and copy Folder

Posted on 2016-08-18
2
42 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 54

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable to access folder shares on Netapp 1 25
New IP's needed ASAP 6 85
Pop-up allow list 6 41
Office 365: Hybrid Migration from Exchange (Retention Policies) 22 90
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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 …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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