Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

iHow to copy files to c:\windows (Permission Denied)

iHow to copy files to c:\windows (Permission Denied)

iHow to copy files to c:\windows (Permission Denied)

I am writing my first VBScript in Win98 SE to do a simple software install.  The first copy (CopyFolder) works just fine, but on the second copy (CopyFile) I get:

           Windows Script Host
              Line:         14
              Error:       Permission Denied
              Code:       800A0046
              Source:    Microsoft VBScript runtime error

How do I fix this?

Here is the script:

'  VB Script to install IrfanView on Drive C:

' Define variables
Dim fso, Irfan_folder, Irfan_ini, MyVar

Set fso = CreateObject("Scripting.FileSystemObject")
Set Irfan_folder = fso.GetFolder("\Irfanview")
Set Irfan_ini = fso.GetFile("\IrfanView\i_view32.ini")

' Copy IrfanView Folder to C:
fso.CopyFolder Irfan_folder, "C:\"

' Copy IrfanView .ini file to C:\Windows
fso.CopyFile "\IrfanView\IrfanView.lnk", "C:\Windows"

MyVar = MsgBox ("IrfanView Install is complete.",0,"Install Success!")


RE: iHow to copy files to c:\windows (Permission Denied)

Hey, i don't see where you are getting the file:


I think you should get the file "IrfanView.lnk" in this statement:

Set Irfan_ini = fso.GetFile("\IrfanView\IrfanView.lnk")

fso.CopyFile Irfan_ini, "C:\Windows"

This puppy should work...

RE: iHow to copy files to c:\windows (Permission Denied)


Thanks for taking the time to answer my post.  The file name in the sample code should have been:  "i_view32.ini", but that's not the real problem  I discovered that the syntax in VBS statements evidently requires the ending "\" on a folder name.  The following code lines DO work:

    Set Irfan_ini = fso.GetFile("\IrfanView\i_view32.ini")

And this is what I have in my working live script.

Alternatively, the following replacement line should work in the original code sample:

   fso.CopyFile "\IrfanView\i-view32.ini", "C:\Windows\"
                                                                             ^ Note backslash

Thanks again.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close