Welcome, Register for free! or Login below:
EduGeek.net RSS Feeds Register FAQ Members Social Groups User Map Calendar Search Today's Posts Mark Forums Read

Scripts If you need or have any scripts then get 'em here.

Go Back   EduGeek.net Forums > Coding and Web Development > Scripts
Reply
 
LinkBack Thread Tools Search Thread
Sponsored Links
Old 07-01-2009, 11:05 AM   #1
 
MicrodigitUK's Avatar
 
Join Date: May 2007
Location: Wiltshire (Sheldon/John of Gaunt)
Posts: 88
uk
Thanks: 4
Thanked 7 Times in 6 Posts
Rep Power: 6 MicrodigitUK is on a distinguished road
Default vbscript to copy a folder & delete a folder

I am having a bit of trouble finding bits of code to produce 2 vbscripts.

One script needs to copy a folder from the directory the script is running in and place it on a location on the c drive. It should over write any files or folders if they already exist.

The second script is to force the deletion of the files and folders copied in the first script from the first script.

Both scripts are part of an unattended install or uninstall. Because they are unattended and to stop students messing up the installs I can’t call a CMD.exe prompt from the script and run commands like xcopy. The students would just close the CMD prompt box.

Any pointers in the correct direction would help.
  Reply With Quote
Old 28-01-2009, 03:20 PM   #2
 
bmittleider's Avatar
 
Join Date: Jan 2009
Location: Nebraska
Posts: 5
usa
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 bmittleider is an unknown quantity at this point
Default

if you can use vbscript take a look at DevGuru VBScript Object: FileSystemObject.

I used the CopyFolder and DeleteFolder methods in a script I created a while back.
  Reply With Quote
Old 29-01-2009, 12:43 PM   #3
 
srochford's Avatar
 
Join Date: Aug 2005
Location: London
Posts: 1,698
uk
Thanks: 9
Thanked 200 Times in 178 Posts
Blog Entries: 1
Rep Power: 47 srochford has much to be proud ofsrochford has much to be proud ofsrochford has much to be proud ofsrochford has much to be proud ofsrochford has much to be proud ofsrochford has much to be proud ofsrochford has much to be proud ofsrochford has much to be proud of
Default

Not quite sure what you're trying to do but something like this might help:

Code:
Set oShell = CreateObject("WScript.Shell")
Set ofso = CreateObject("Scripting.FileSystemObject")

sFolder=oFSO.GetParentFolderName(Wscript.ScriptFullName)

ofso.copyfolder sFolder,"c:\temp\test",true

'do something

ofso.deletefolder "c:\temp\test",true
First three lines work out "where am I now"; next line copies everything that's in the same folder as the script to a folder called "test" under c:\temp - change that to whatever you want.
????: EduGeek.net Forums http://www.edugeek.net/forums/scripts/28602-vbscript-copy-folder-delete-folder.html

I'm guessing you then want to run some kind of setup process from that folder so do that at the "do something" bit and the final line deletes the folder just copied.

The two "true" flags will overwrite anything that was already in c:\temp\test and the second one deletes files which are read-only
  Reply With Quote
Reply
Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't delete corrupt folder cookie_monster Windows 7 19-09-2008 08:36 AM
Delete a folder using Vbscript soze How do you do....it? 1 02-06-2008 08:59 PM
Script to delete folder and all sub-folders in a shared folder JPhillips173 Scripts 2 17-04-2008 11:25 AM
Delete a folder using scripting FN-GM Scripts 15 22-12-2007 04:44 PM
Got a folder I cannot delete or take ownership of sidewinder Windows 2 20-03-2007 02:49 PM



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search Thread
Search Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:00 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright EduGeek.net




website uptime

© 2005 - 2009 EduGeek.net
no new posts