Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an old Javascript that we run on installs here (with cscript) that stopped working properly somewhere after the beginning of last year. I'm trying to figure out why.

It looks like the CopyFolder method of the FileSystemObject isn't copying over all the files it needs to. Even if the target directory does not exist, the copy will fail after copying most of the files with "Permission Denied".

The code is roughly the following:

try {
        "C:\\Program Files\\Microsoft Visual Studio 8\\VC\\\VCWizards\\CodeWiz\\Generic\\", true);
} catch (e) {
    WScript.Echo ("CodeWiz Folder copy failed: " + e.message);

What I'm seeing (again, even if the destination directory doesn't exist), is that all 12 folders get copied over, but only 25 of the 31 files (missing all 5 from one directory, and one from the root directory). The message I see if I run the script manually is: "CodeWiz Folder copy failed: Permission denied"

None of the source files appear to be read-only or hidden, and the same folder copy works just fine if I do it manually via explorer. I'm running as a user in the Admin group. I'm seeing this behavior both on Windows 7 32 and 64 bit.

Any idea what's going on here?

share|improve this question
are you running your script with admin privileges? the folders you are creating are likely inheriting permissions from their parent, and everything in Program Files is usually restricted to admins for write. – Frank Thomas Aug 28 '13 at 14:21
@FrankThomas - I'm running from an account in the administrators group. – T.E.D. Aug 28 '13 at 14:29
on windows-7, unless you are running it as an automated task, you will still need to execute the shell running the script as admin (RClick -> Run as Administrator). being an admin in win7 just means that you can elect to become admin, not that every process you execute has administrative privileges. – Frank Thomas Aug 28 '13 at 14:44
@FrankThomas - Fair enough. Just tried it from a command shell I started with RClick -> Run as Administrator, and I get the same behavior. – T.E.D. Aug 28 '13 at 18:43
looks like you have too many \'s between VC and VCWizards. what happens if you use only two there? – Frank Thomas Aug 28 '13 at 19:09

You must log in to answer this question.

Browse other questions tagged .