VBscript Permission Denied 800A0046 Solution

I was helping a friend write some VBscript the other day. I was trying to write a simple copy function and I kept getting permission denied. However I was logged in locally as the administrator so that could not be it.

My code looked something like:

Sub CopyFile(source, destination)
	set filesys=CreateObject("Scripting.FileSystemObject")
	If filesys.FileExists(source) Then
	   filesys.CopyFile source, destination
	End If
End Sub

The Solution is: add “\” add the end of any of your path names like
Dim destinationpath
destinationpath = “C:\” & myfolder & “\”

Hope this helps someone else.

Be Sociable, Share!

Tags: , , , , , , ,

Friday, June 26th, 2009 Desktop Enginnering, Programming

8 Comments to VBscript Permission Denied 800A0046 Solution

Tom
January 25, 2010

You must be a freaking genius!!! Thank you!

gacsalyi
April 15, 2010

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

see
http://www.tek-tips.com/viewthread.cfm?qid=62827&page=590

Tvede
December 4, 2010

Saved the day – stupid error forgetting the last “\”.. Cheers!

Sammy
July 20, 2011

Thanks mate. Been sitting here for the last half an hour wondering why…

omar
January 25, 2012

Very helpful post. Thanks a mill

dpb
March 9, 2012

Very helpful, thank you!!

Elias Santiago
March 29, 2012

Finally! I was editing a 200+ vbs login script and got stuck on this error. Everything seemed fine, but the “Permission denied”. Even checked the permissions on both the source and destination folders, no good.

Then I found this post and VOILA!!! Everything is good again and I’m a happy camper!!

THANK YOU SO MUCH!

Jim Gillmore
May 7, 2012

Thank you, your post moved me off dead center.

Leave a comment