Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Copy/Access Denied Error

Status
Not open for further replies.

husweety

IS-IT--Management
Sep 24, 2007
2
US
I am in the process of creating a VBSCript that creates a folder and then copies files from one folder on my C drive to the new folder created on my C drive.
When trying to copy or move the files I get a "Cannot Copy: Access is Denied, Make sure the disk is not full or write protected and that the file is not currently in use" error.

I dont understand this error because I have admin writes and the files I am trying to move are random empty text files I created in notepad just to test my script.
Any suggestions???
Here is the code I have so far.

'**********************************************************
'The first step to create the folder
'**********************************************************

strMonth = Month(Date)

If Len(strMonth) = 1 Then
strMonth = "0" & strMonth
End If

strDay = Day(Date)-1

If Len(strDay) = 1 Then
strDay = "0" & strDay
End If

strYear = Year(Date)

strFolderName = "C:\temp\backup\09-2007\" & strMonth & "-" & strDay & "-" & strYear

Set objFSO = CreateObject("Scripting.FileSystemObject")

Wscript.Echo "Yesterday's Date: " & strMonth & "-" & strDay & "-" & strYear

If objFSO.FolderExists (strFolderName) Then
Wscript.Echo "Folder exists."
Else
Set objFolder = objFSO.CreateFolder(strFolderName)
End If
'***********************************************************
'The second step to copy files to a new folder, while
'showing the copy status box
'***********************************************************
Const FOF_CREATEPROGRESSDLG = &H0&

strTargetFolder = "C:\scripts"

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(strTargetFolder)

objFolder.CopyHere "C:\temp\*.*", FOF_CREATEPROGRESSDLG
 
Which line is generating the error? Have you tried the CopyFile or CopyFolder methods of FSO

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
The first step works fine, the entire second step is the only part that will not execute because I get the cannot copy error.
Yes I have tried the CopyFile/CopyFolder, MoveFile/MoveFolder methods and get the same exact error.
Is there some kind of rights I have to give the files I am copying or something?....Like I said the files I am copying are random empty text files I created in notepad just to test my script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top