Follow via:
RSS
Email Alert
Question
0 Votes
+ -

Cannot Copy Error

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
24th Sep 2007

Answers (1)

0 Votes
+ -
I'm just guessing here but...
Why do you go thru all the trouble of creating a dated folder if you're copying the files to "C:\scripts"? Does that folder even exist?

Ralph
24th Sep 2007

Replies

I created c:\temp, c:\script, and all of their components just to test my script. They are simply test files and test folders mostly empty and meaningless.
Regardless of the folders being created, the entire first step works fine, it is the second step I am having trouble with, copying a simple text file to the new folder.
husweety@... 25th Sep 2007
You say you've created these 'empty' files in Notepad.

Have you, by any chance, been leaving Notepad running in the background, with one or other of these files still active?
OldER Mycroft 25th Sep 2007
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.