I am trying to unzip a file to my HD

Author Message
longbow22

  • Total Posts : 6
  • Scores: 0
  • Reward points : 0
  • Joined: 12/19/2011
  • Status: offline
I am trying to unzip a file to my HD Monday, December 26, 2011 12:51 AM (permalink)
0
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 

 
#1
    longbow22

    • Total Posts : 6
    • Scores: 0
    • Reward points : 0
    • Joined: 12/19/2011
    • Status: offline
    Re:I am trying to unzip a file to my HD Monday, December 26, 2011 8:54 AM (permalink)
    0
    I am starting to figure my script out, if I comment out any line that begins with wscript I can get the script to partially work.
    Am I not creating a wscript instance or something like that?
     
    LB
     
    #2
      ebgreen

      • Total Posts : 8227
      • Scores: 98
      • Reward points : 0
      • Joined: 7/12/2005
      • Status: offline
      Re:I am trying to unzip a file to my HD Tuesday, December 27, 2011 4:01 AM (permalink)
      0
      So not even something like this works:
       
      WScript.Echo "FOO"
      "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
      Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
      http://www.visualbasicscript.com/m_47117/tm.htm
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9