Question

Locked

Cannot Copy Error

By husweety ·
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

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

I'm just guessing here but...

by JackOfAllTech In reply to Cannot Copy Error

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

Collapse -

Test files/folders

by husweety In reply to I'm just guessing here bu ...

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.

Collapse -

Here's another guess ...

by OldER Mycroft In reply to Test files/folders

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?

Back to Hardware Forum
4 total posts (Page 1 of 1)  

Hardware Forums