Hello,
I am trying to use the below to unzip a file from a thumbdrive to my HD, I get an error on this line:
objShell.NameSpace(ParentFolder).CopyHere objShell.NameSpace(strFrom).Items
Plus none of the echos work Wscript.Echo
I am new to scripting, so I know its got to be something simple, I just dont understand fully how objShell, objFSO, objFolder, and namespace stuff works.
I've read what I can in previous posts, but its just not clicking.
TY
LB
Function Unzip(strFrom,strTo,FileType)
Dim ParentFolder
Dim objShell, objFSO, objFolder
Dim strThumbDrive, strLocalFile, strLocalFolderName Set objShell = CreateObject("Shell.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject") ' We need to get the path of the thumb drive we are using
Set objFile = objFSO.GetFile("Menu.hta") strThumbDrive = objFSO.GetParentFolderName(objFile)
strLocalFile = objFSO.GetParentFolderName(objFile) & strFrom
strLocalFolderName = "C:\Rent Roll\" ' For this to work we need to zip the CONTENTS of C:\Rent Roll not including the main folder name C:\Rent Roll
ParentFolder = "C:\"
' Create folder to receive files if it doesn' t already exist If objFSO.FolderExists(strTo) Then
Wscript.Echo "Folder exists."
'BackupFiles strThumbDrive,strLocalDir,strToDir
Set objFolder = objShell.NameSpace(ParentFolder)
Set objFolder = objFSO.GetFolder(strLocalFolderName)
objShell.NameSpace(ParentFolder).CopyHere objShell.NameSpace(strFrom).Items
Wscript.Echo "Unzipped the new version of the Rent Roll to C:\Rent Roll"
Else
Wscript.Echo "Folder does not exist."
install = MsgBox ("Tenant Tracker not installed..." & Chr(13) & "Click Ok to install or Cancel to quit...",1)
If intall = vbOk Then
If FileType = 1 Then
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install(objFSO.GetParentFolderName(objFile) & "TenantTracker2011Full.msi", , ALL_USERS)
Else
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install(objFSO.GetParentFolderName(objFile) & "TenantTracker2011Demo.msi", , ALL_USERS)
End If
Else
Self.close
End If
End If
Set objFSO = Nothing
Set objFolder = Nothing
Set objShell = Nothing
Self.close
End Function