Sunday, March 9, 2014

WshShell | Code to Extract ZIP file

Function ExtractZIP(zipFilePath)
Dim arrFile, pathToZipFile, extractTo

arrFile = Split(zipFilePath, ".")     ' Split file path with file extension
Set fso = CreateObject("Scripting.FileSystemObject")    ' Create fso object to create/delete intermediate files...etc.,
fso.CreateFolder(arrFile(0) & "\")     'creating a folder with same name and location
pathToZipFile= arrFile(0) & ".zip"
extractTo= arrFile(0) & "\"

set objShell = CreateObject("Shell.Application")     'creating shell object
        ' code to extract the zip file and copy to same specified folder
set filesInzip=objShell.NameSpace(pathToZipFile).items
'fso.DeleteFile pathToZipFile, True    ' deleting zip file after the extraction.
Set fso = Nothing
Set objShell = Nothing
End Function

WshShell | Code to Count the Number Of IE Browsers Opened

Dim shie
set sh  = CreateObject("shell.application").windows
msgbox sh.Count
set sh=nothing