I have a batch script that does the following tasks.
1. Create a backup folder
2. Zip specific files (text files in .log format) and move zipped files to backup folder
3. Delete the original files after moving
To accomplish the 2nd task, I'm writing the commands into VBScript file from batch script like below and then executing the VBScript at the end of batch script.
echo Option Explicit >> zipIt.vbs
REM remaining commands
CScript zipIt.vbs
The batch script successfully performs all 3 tasks for a file of size 100 MB. But fails at VBScript command for file of size 1 GB. Following error is thrown at command prompt
C:\Users\Administrator\Desktop\zipIt.vbs(18, 1) Microsoft VBScript runtime error
: Permission denied
Below is the content of zipIt.vbs Written line numbers here for convenience.
1. Option Explicit
2. Dim FileToZip, Result
3. Dim oShell
4. Dim file
5. Dim oFileSys
6. Dim winShell
7. FileToZip = "C:\Program Files\logs\File_2013-04-29.log"
8. Result = "C:\Program Files\logs\File_2013-04-29.log.zip"
9. Set oShell = CreateObject("WScript.Shell")
10. Set oFileSys = CreateObject("Scripting.FileSystemObject")
11. Set file = oFileSys.CreateTextFile(Result, True)
12. file.Write "PK" & Chr(5) & Chr(6) & String(18, 0)
13. file.Close
14. Set file = nothing
15. set winShell = createObject("shell.application")
16. winShell.namespace(Result).CopyHere FileToZip
17. wScript.Sleep(5000)
18. oFileSys.DeleteFile FileToZip
Getting the same error if VBScript is run alone. Is it because of large file size?
File_2013-04-29.log.zipBut it fails to add the .log file and delete the original file. - Shrik