+ Post New Thread
Results 1 to 3 of 3
Scripts Thread, vbscript to copy a folder & delete a folder in Coding and Web Development; ...
  1. #1
    MicrodigitUK's Avatar
    Join Date
    May 2007
    Thank Post
    Thanked 56 Times in 52 Posts
    Rep Power

    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.

  2. #2
    bmittleider's Avatar
    Join Date
    Jan 2009
    Thank Post
    Thanked 0 Times in 0 Posts
    Rep Power
    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.

  3. #3

    Join Date
    Aug 2005
    Thank Post
    Thanked 529 Times in 452 Posts
    Blog Entries
    Rep Power
    Not quite sure what you're trying to do but something like this might help:

    Set oShell = CreateObject("WScript.Shell")
    Set ofso = CreateObject("Scripting.FileSystemObject")
    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.

    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

+ Post New Thread

Similar Threads

  1. Can't delete corrupt folder
    By cookie_monster in forum Windows
    Replies: 7
    Last Post: 19th September 2008, 09:36 AM
  2. Delete a folder using Vbscript
    By soze in forum How do you do....it?
    Replies: 1
    Last Post: 2nd June 2008, 09:59 PM
  3. Replies: 2
    Last Post: 17th April 2008, 12:25 PM
  4. Delete a folder using scripting
    By FN-GM in forum Scripts
    Replies: 15
    Last Post: 22nd December 2007, 05:44 PM
  5. Got a folder I cannot delete or take ownership of
    By sidewinder in forum Windows
    Replies: 2
    Last Post: 20th March 2007, 03:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts