Jump to content

Recommended Posts

Posted

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.

  • 3 weeks later...
Posted

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")

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.

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...