Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

.vbs unzipping question

  • 12-11-2008 9:48am
    #1
    Registered Users, Registered Users 2 Posts: 538 ✭✭✭


    Hi All,

    New to .vbs. I have found a script

    [PHP]
    pathToZipFile="C:\index.zip"
    extractTo="C:\"

    set sa = CreateObject("Shell.Application")
    set filesInzip=sa.NameSpace(pathToZipFile).items
    sa.NameSpace(extractTo).CopyHere(filesInzip)
    [/PHP]

    That will unzip the zip to the c drive now i want to update this code because i want to drag and drop the zip file on the actual .vbs file itself that would give me the pathToZipFile var

    I then want to extract the zip to a folder sitting beside the .vbs file called "content" now this will be on a few machines so i dont have the paths.

    I thne found this script

    [PHP]Dim ObjFile, strDestination
    Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
    Dim Act : Set Act = CreateObject("Wscript.Shell")
    Dim FldrDate : FldrDate = WeekdayName(Weekday(Date),True) & "-" & Replace(Date,"/","-")
    Dim SysCopy : SysCopy = Act.ExpandEnvironmentStrings("%SystemDrive%\Arch_CopyTo_" & FldrDate &"\")
    Dim ArgCnt : ArgCnt = WScript.Arguments.Count
    If ArgCnt = 1 Then
    '/-> Passes The Full Path And File Name As A Argument
    Set ObjFile = Fso.GetFile(Wscript.Arguments(0))
    '/-> Get It Name From The Drag And Drop
    strDestination = SysCopy & ObjFile.Name
    '/-> Check For The destination Folder
    If Not Fso.FolderExists(SysCopy) Then Fso.CreateFolder(SysCopy) End If
    '/-> Set To Over Write File If Exists
    ObjFile.Copy(strDestination),True
    Act.Popup "Completed The Copy From" & vbCrLf & Wscript.Arguments(0) & vbCrLf &_
    "To This Location Here" & vbCrLf & strDestination, 5, "Copy Completed",0 + 32 + 48
    Else
    '/-> If No File Was Drop On To The Script
    Act.Popup "Error No File Was Drop On This Script" & _
    "To Copy The File It Must Be Place On" & vbCrLf & _
    WScript.ScriptFullName, 15,"Error", 0 + 48 + 4096
    Wscript.Quit
    End If[/PHP]

    This has the drag and drop functionality and it know where the script is using

    [PHP]vbCrLf[/PHP] and [PHP]Fso.GetFile(Wscript.Arguments(0))[/PHP] , now i need to get a combination of both however i think my trouble is in object to string conversion or is it? Any help very much appriciated.

    M


Comments

  • Registered Users, Registered Users 2 Posts: 538 ✭✭✭mjquinno


    ok got it to work

    using this code

    [PHP]extractTo = left(WScript.ScriptFullName,(Len(WScript.ScriptFullName))-(len(WScript.ScriptName)))
    extractTo =extractTo & "content"


    Set objArgs = WScript.Arguments
    If objArgs.Count =1 then

    pathToZipFile=objArgs(0)


    set sa = CreateObject("Shell.Application")
    set filesInzip=sa.NameSpace(pathToZipFile).items
    sa.NameSpace(extractTo).CopyHere(filesInzip)

    Else
    End If[/PHP]


Advertisement