Computer Hope

Microsoft => Microsoft Windows => Windows XP => Topic started by: JOhnathan.Pierce on April 22, 2013, 08:17:12 AM

Title: Please help me alter this script
Post by: JOhnathan.Pierce 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
Title: Re: Please help me alter this script
Post by: Salmon Trout 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?




Title: Re: Please help me alter this script
Post by: cengbrecht 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.
Title: Re: Please help me alter this script
Post by: Salmon Trout 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.

Title: Re: Please help me alter this script
Post by: BC_Programmer 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.