简体   繁体   中英

Copy specific file to current directory - Microsoft VBScript runtime error '800a0046'

How to Copy specific file to current directory : I get the following error:

Microsoft VBScript runtime error '800a0046' Permission denied

line :5 Char: 1

When running a simple copy:

dim fso
set fso = CreateObject("Scripting.FileSystemObject")
dim CurrentDirectory
CurrentDirectory = fso.GetAbsolutePathName(".")
fso.CopyFile "d:\eula.1028.txt", "D:\Back up"

Have you already checked for user permission on destination folder?

I didn't noticed the fact that you didn't specified the name of the file in the destination. It sholud be as follows:

fso.CopyFile "d:\\eula.1028.txt", "D:\\Back up\\eula.1028.txt"

or specify another neew different name for the destination.

Angelo.

It can be as follows to a specific file to current directory:

dim fso
set fso = CreateObject("Scripting.FileSystemObject")
dim CurrentDirectory
CurrentDirectory = fso.GetAbsolutePathName(".")
fso.CopyFile "d:\eula.1028.txt", "CurrentDirectory", True

You might be getting this error by not including the last \\ on the destination path.

D:\\Back up instead of D:\\Back up\\

A little more information about the syntax here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM