Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

VBScript - Extract ZIP

Created: 30 Nov 2012 • Updated: 02 Dec 2012 | 1 comment
This issue has been solved. See solution.

Hi,

Another post, this time about vbscript.

Here is a vbscript which will just extract the contents of a zip file at a given location to wherever I want it to, but I just can't get it working when I add it into a WiseScript, I'm calling it with an Execute VBscript command....

-------------------------------------------------------------------------------------

Const NOCONFIRMATION = &H10&
Const NOERRORUI = &H400&
Const SIMPLEPROGRESS = &H100&

cFlags = NOCONFIRMATION + NOERRORUI + SIMPLEPROGRESS

strZipFile = "Mobile\03 - Quick Address\AddressBase.zip"
outFolder = "C:\QAddress"

strCurrDir = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))

'If the output folder does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(outFolder) Then
   fso.CreateFolder(outFolder)
End If

Set objShell = CreateObject( "Shell.Application" )
Set objSource = objShell.NameSpace(strCurrDir+strZipFile).Items()
Set objTarget = objShell.NameSpace(outFolder)
objTarget.CopyHere objSource, cFlags

-------------------------------------------------------------------------------------

The line it fails on is the one highlighted in bold. If I run this from Windows it works just fine. Infact in the example given above, it will find the file called AddressBases.zip from the relative path of where it is run from, and then extract the contents to the outFolder at C:\QAddress.

When I put it into WiseScript and call it, it errors with 'Object doesn't support this property or method - WScript.ScriptFullName'

I've seen examples of this command being used within this forum so I think it should work but it's not for me? I'm a bit stumped to be honest, any help would be greatly appreciated. Using Wise Script Editor 8 and testing on Win Server 2008 at the moment.

Discussion Filed Under:

Comments 1 CommentJump to latest comment

Paul1977's picture

Ok, fixed it with this....

Const NOCONFIRMATION = &H10&
Const NOERRORUI = &H400&
Const SIMPLEPROGRESS = &H100&
 
cFlags = NOCONFIRMATION + NOERRORUI + SIMPLEPROGRESS
 
strZipFile = "\AddressBase.zip"
outFolder = "C:\QAddress"

Set fso = CreateObject("Scripting.FileSystemObject") 
Set f1 = fso.GetFolder(".\Mobile\03 - Quick Address")

'If the output folder does not exist create it.
 If Not fso.FolderExists(outFolder) Then
    fso.CreateFolder(outFolder)
 End If
 
Set objShell = CreateObject("Shell.Application")
Set objSource = objShell.NameSpace(f1+strZipFile).Items()
Set objTarget = objShell.NameSpace(outFolder)
objTarget.CopyHere objSource, cFlags

SOLUTION