Hello All,
I am just beginning in vbScript so please excuse the mess you may find in my code.
I am receiving a permission denied error code 800A0046 when I run FleCmpr.vbs.
If I run CopFle.vbs, I don't get this error copying\moving from and to the same directories.
I DO have permissions, twice over, once as domain admin and once directly on the directory in question, MatchDir.
This is in evidence because CopFle.vbs DOES work.
The only difference I can see here is the use of variables for the file names and I can't get around that, at least not with the limited knowledge I have.
I have read all six threads on this error and again, it is NOT a permissions issue.
This code does a perfect file comparison between two file or 200 files, I just need to copy the offending files to a special directory for my billing staff to repair.
Any assistance, suggestions, criticism will be appreciated.
rnpIII
-----------------------------------Code Below-----------------------------------
' FleCmpr.vbs
Const HomeDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI"
Const WorkDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work"
Const BinDir = "\\FILES01\Home\It\Batches\Bin\"
Const TmpDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Temp"
Const LogDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work\Logs"
Const MatchDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work\Match\"
Dim file, fileII, FnmI, FnmII
Dim Verifso, VeriFle, FIfso, FIIfso, FI, FII, strFI, strFII
Dim fldr, PauseBtn, SizeVar
Dim Tmpfso, TmpFle
Set Tmpfso = CreateObject("Scripting.FileSystemObject")
Set TmpFle = Tmpfso.CreateTextFile(LogDir & "\Verified Files.txt", True)
Set Verifso = CreateObject("Scripting.FileSystemObject")
Set VeriFle = Verifso.CreateTextFile(LogDir & "\Match.txt", True)
Set FVarfso = CreateObject("Scripting.FileSystemObject")
Set FIfso = CreateObject("Scripting.FileSystemObject")
Set FIIfso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fldr = FVarfso.GetFolder(WorkDir)
' Get the file names from the Work directory
' Then get the second file name to compare with
For Each File in fldr.Files 'first file name to retrieve
For Each FileII In fldr.Files 'second file name to retrieve
FnmI = FVarfso.GetFilename (File)
FnmII = FVarfso.GetFilename (FileII)
TmpFle.WriteLine "Checking " & FnmI & " and " & FnmII ' Write to Verified Files.txt
If File <> FileII then ' If the names of the files do not match
Set FI = FIfs
penTextFile(File)
Set FII = FIIfs
penTextFile(FileII)
strFI = FI.ReadLine
strFII = FII.ReadLine
If strFI = strFII then ' Compare the first line of each file to see if they
' are identical
VeriFle.WriteLine FnmI & " and " & FnmII & " are identical" ' Write to
' names of duplicate files to Match.txt
'wscript.echo "Moving " & FnmI & " and " & FnmII
'FIfso.CopyFile WorkDir & "\Test.txt", MatchDir
'FIIfso.CopyFile FileII, MatchDir
MvFle 'FnmI, FnmII
End If
End If
Next
'Call PauseFunc ' Pause for error checking
Next
Set Verifso = CreateObject("Scripting.FileSystemObject")
Set VeriFle = Verifso.GetFile(LogDir & "\Match.txt")
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshEnv = WshShell.Environment("Volatile")
SizeVar = VeriFle.Size
If SizeVar <= 0 Then
Verifso.DeleteFile(VeriFle)
End If
Function PauseFunc ' Function to allow the script to pause and be cancelled
PauseBtn = WshShell.Popup("Click CANCEL to cancel script", 5, "Checking!", 1 + 32)
Select Case PauseBtn
case 2 WScript.Quit
case -1
End Select
End Function
'Moved it to a function so I could watch it better
Function MvFle '(FnmI, FnmII)
FIfso.MoveFile WorkDir &"\"& FnmI, MatchDir &"\"
'FIIfso.MoveFile FileII, MatchDir & FnmII
End Function
-----------A piece of code that works fine-------------
'CopFle.vbs
Const WorkDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work"
Const MatchDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work\Match"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile WorkDir &"\testi.txt", MatchDir &"\"
I am just beginning in vbScript so please excuse the mess you may find in my code.
I am receiving a permission denied error code 800A0046 when I run FleCmpr.vbs.
If I run CopFle.vbs, I don't get this error copying\moving from and to the same directories.
I DO have permissions, twice over, once as domain admin and once directly on the directory in question, MatchDir.
This is in evidence because CopFle.vbs DOES work.
The only difference I can see here is the use of variables for the file names and I can't get around that, at least not with the limited knowledge I have.
I have read all six threads on this error and again, it is NOT a permissions issue.
This code does a perfect file comparison between two file or 200 files, I just need to copy the offending files to a special directory for my billing staff to repair.
Any assistance, suggestions, criticism will be appreciated.
rnpIII
-----------------------------------Code Below-----------------------------------
' FleCmpr.vbs
Const HomeDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI"
Const WorkDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work"
Const BinDir = "\\FILES01\Home\It\Batches\Bin\"
Const TmpDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Temp"
Const LogDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work\Logs"
Const MatchDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work\Match\"
Dim file, fileII, FnmI, FnmII
Dim Verifso, VeriFle, FIfso, FIIfso, FI, FII, strFI, strFII
Dim fldr, PauseBtn, SizeVar
Dim Tmpfso, TmpFle
Set Tmpfso = CreateObject("Scripting.FileSystemObject")
Set TmpFle = Tmpfso.CreateTextFile(LogDir & "\Verified Files.txt", True)
Set Verifso = CreateObject("Scripting.FileSystemObject")
Set VeriFle = Verifso.CreateTextFile(LogDir & "\Match.txt", True)
Set FVarfso = CreateObject("Scripting.FileSystemObject")
Set FIfso = CreateObject("Scripting.FileSystemObject")
Set FIIfso = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fldr = FVarfso.GetFolder(WorkDir)
' Get the file names from the Work directory
' Then get the second file name to compare with
For Each File in fldr.Files 'first file name to retrieve
For Each FileII In fldr.Files 'second file name to retrieve
FnmI = FVarfso.GetFilename (File)
FnmII = FVarfso.GetFilename (FileII)
TmpFle.WriteLine "Checking " & FnmI & " and " & FnmII ' Write to Verified Files.txt
If File <> FileII then ' If the names of the files do not match
Set FI = FIfs
Set FII = FIIfs
strFI = FI.ReadLine
strFII = FII.ReadLine
If strFI = strFII then ' Compare the first line of each file to see if they
' are identical
VeriFle.WriteLine FnmI & " and " & FnmII & " are identical" ' Write to
' names of duplicate files to Match.txt
'wscript.echo "Moving " & FnmI & " and " & FnmII
'FIfso.CopyFile WorkDir & "\Test.txt", MatchDir
'FIIfso.CopyFile FileII, MatchDir
MvFle 'FnmI, FnmII
End If
End If
Next
'Call PauseFunc ' Pause for error checking
Next
Set Verifso = CreateObject("Scripting.FileSystemObject")
Set VeriFle = Verifso.GetFile(LogDir & "\Match.txt")
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set WshEnv = WshShell.Environment("Volatile")
SizeVar = VeriFle.Size
If SizeVar <= 0 Then
Verifso.DeleteFile(VeriFle)
End If
Function PauseFunc ' Function to allow the script to pause and be cancelled
PauseBtn = WshShell.Popup("Click CANCEL to cancel script", 5, "Checking!", 1 + 32)
Select Case PauseBtn
case 2 WScript.Quit
case -1
End Select
End Function
'Moved it to a function so I could watch it better
Function MvFle '(FnmI, FnmII)
FIfso.MoveFile WorkDir &"\"& FnmI, MatchDir &"\"
'FIIfso.MoveFile FileII, MatchDir & FnmII
End Function
-----------A piece of code that works fine-------------
'CopFle.vbs
Const WorkDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work"
Const MatchDir = "\\FILES01\Home\Billing\Day_Proc\AdminiSource\CISI\Work\Match"
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile WorkDir &"\testi.txt", MatchDir &"\"