Created
October 23, 2016 15:23
-
-
Save gjyoung1974/58f191c49dd76c0c654e352427c6d6f2 to your computer and use it in GitHub Desktop.
JScript create a zip file of a log directory in MSFT Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a zip file of the log directory.. | |
function f_CreateZip() { | |
var shell = new ActiveXObject("Shell.Application"); | |
var fs_obj = new ActiveXObject("Scripting.FileSystemObject"); | |
var zipFilename = strLogPath.path + '\\' + sActiveConfig + '-LogFiles.zip'; | |
// create an empty zipfile :-) | |
var zipFile = fs_obj.CreateTextFile(zipFilename, 1, 0); | |
zipFile.Write('PK' + String.fromCharCode(5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)); | |
zipFile.Close(); | |
var source = strLogPath.path + '\\Logs'; | |
// Test if is null folder | |
if (source == null) { | |
// throw new TypeError(); | |
} | |
// copy all the source files into the zipfile | |
shell.NameSpace(zipFilename).CopyHere(source); | |
WScript.Sleep(2000); | |
// delete directory | |
fs_obj.DeleteFolder(strLogPath.path + '\\Logs'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment