Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Please help me alter this script  (Read 3166 times)

0 Members and 1 Guest are viewing this topic.

JOhnathan.Pierce

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    Please help me alter this script
    « on: April 22, 2013, 08:17:12 AM »
    Hello,

    I need this to create a folder if one doesn't exist. I keep getting an error objtarget required on line 21 char 1.

    Thank you!

    Code: [Select]
    strPath = "Path"

    DeleteFolder strPath

    Function DeleteFolder(strFolderPath)
    Dim objFSO, objFolder
    Set objFSO = CreateObject ("Scripting.FileSystemObject")
    If objFSO.FolderExists(strFolderPath) Then
    objFSO.DeleteFolder strFolderPath, True
    End If
    Set objFSO = Nothing


    strZipFile = "Path"                            'name of zip file
    outFolder = "Path"                            'destination folder of unzipped files
    Set objShell = CreateObject( "Shell.Application" )
    Set objSource = objShell.NameSpace(strZipFile).Items()
    Set objTarget = objShell.NameSpace(outFolder)
       
    intOptions = 4 +  16 + 1024
    objTarget.CopyHere objSource, intOptions
    End Function

    Salmon Trout

    • Guest
    Re: Please help me alter this script
    « Reply #1 on: April 22, 2013, 09:58:00 AM »
    What are all those "path" things? Do they represent different files and folders? Why are they disguised? Could you talk me through what you think the code should do? If you want to create a folder if it doesn't exist, why have you got a function called Deletefolder that deletes a folder if it does exist? And why is code to extract from a zip file inserted in the middle of it?




    « Last Edit: April 22, 2013, 10:16:48 AM by Salmon Trout »

    cengbrecht



      Beginner

      Thanked: 4
      • Yes
      • Memory Express
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Please help me alter this script
    « Reply #2 on: April 22, 2013, 11:33:49 AM »
    It looks like he is trying to make a tool to automatically extract a zip file to his harddrive by just dragging the file over the script.
    However, as to how to fix it, I am not sure. But Line 21 is the second last line, so its something in that part that is seeing an issue.
    E=mc˛ -- Who knows if this applies, but hey everyone will think I am smart now!

    Salmon Trout

    • Guest
    Re: Please help me alter this script
    « Reply #3 on: April 22, 2013, 12:01:37 PM »
    It looks like he is trying to make a tool to automatically extract a zip file to his harddrive by just dragging the file over the script.
    However, as to how to fix it, I am not sure. But Line 21 is the second last line, so its something in that part that is seeing an issue.

    I don't have a comprehension problem. I know perfectly well what he is trying to do; and I also know perfectly well how to fix his script. What I am trying to establish is whether he is just copying any old script that he finds on the web, that doesn't even do what he wants, and expecting someone on here to write his script for him.


    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Please help me alter this script
    « Reply #4 on: April 22, 2013, 02:29:25 PM »
    For a script that deletes folders it is doing an awful lot that isn't deleting folders.
    I was trying to dereference Null Pointers before it was cool.