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
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