This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: VBscript with DeleteFolder custom action issue
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 02, 2010
08:03 AM
VBscript with DeleteFolder custom action issue
I have an install that will an app that when run will generate a bunch of new folders and files under it main install directory.
So I figured that I would simply create a quick VBScript that will check for the existance of these folders and have them deleted on uninstall.
When I run the custom actions I get the following 1720 error:
"There is a problem with this Windows Install package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action DeleteFolderCA script error -2146828212, Microsoft VBScript runtime error: Path not found Line 26, Column 2."
Now it states that the Path is not found, but I do not think that is the exact error as my code does a check for the existance of the folder before deleting it. Here is that code snipet:
If (objFSO.FolderExists(oFolder)) Then
MsgBox "The folder " & oFolder & " exists so now to delete it.", vbInformation
objFSO.DeleteFolder(oFolder)
MsgBox "The folder " & oFolder & " should now be deleted.", vbInformation
End If
So what else can cause this error as I use this code in a different project and it seems to work correclty???
Also if there is a better way to handle the deletion of folders and files created by the app then let me know about them.
Thanks,
So I figured that I would simply create a quick VBScript that will check for the existance of these folders and have them deleted on uninstall.
When I run the custom actions I get the following 1720 error:
"There is a problem with this Windows Install package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action DeleteFolderCA script error -2146828212, Microsoft VBScript runtime error: Path not found Line 26, Column 2."
Now it states that the Path is not found, but I do not think that is the exact error as my code does a check for the existance of the folder before deleting it. Here is that code snipet:
If (objFSO.FolderExists(oFolder)) Then
MsgBox "The folder " & oFolder & " exists so now to delete it.", vbInformation
objFSO.DeleteFolder(oFolder)
MsgBox "The folder " & oFolder & " should now be deleted.", vbInformation
End If
So what else can cause this error as I use this code in a different project and it seems to work correclty???
Also if there is a better way to handle the deletion of folders and files created by the app then let me know about them.
Thanks,
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 03, 2010
12:53 PM
Clearly it thinks that the path given in your oFolder variable doesn't exist, so maybe the variable isn't set, or set incorrectly?
I'm not sure how you've constructed your custom action vbscript, obviously, but typically I will set the code up in a standalone script and run it on the target server to see where it gets lost.
I use a tool called VBSEdit which uses Microsoft Script Debugger to allow me to walk through the code and query the values of all variables, check whether objects are set correctly, etc. The trial version will allow you to debug, it's drawback is that you have to wait X+1 number of seconds between each stopping point in the debugger.
I'm not sure how you've constructed your custom action vbscript, obviously, but typically I will set the code up in a standalone script and run it on the target server to see where it gets lost.
- Put a MsgBox just before it runs that code.
- Copy your vbscript into a temp folder on the target server
- Run the vbscript from the temp folder to debug
I use a tool called VBSEdit which uses Microsoft Script Debugger to allow me to walk through the code and query the values of all variables, check whether objects are set correctly, etc. The trial version will allow you to debug, it's drawback is that you have to wait X+1 number of seconds between each stopping point in the debugger.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 03, 2010
04:00 PM
Please post the entire CA. I'd like to see how you are creating the fso...
Not that it is the problem - but if you are creating it like this:
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
it will not work. Only in InstallShield you must do it like this:
Dim fso
Set fso = CreateObject("Scripting.Filesystemobject")
note that it drops the WScript.
Now that may not be your problem, but I thought I'd mention it since it's a very common mistake for people creating CA's in VBScript.
Des
Not that it is the problem - but if you are creating it like this:
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
it will not work. Only in InstallShield you must do it like this:
Dim fso
Set fso = CreateObject("Scripting.Filesystemobject")
note that it drops the WScript.
Now that may not be your problem, but I thought I'd mention it since it's a very common mistake for people creating CA's in VBScript.
Des
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 06, 2010
09:44 AM
Here is the entire script that I am using:
' ********************************************
Dim sInstallDirectory
' Get the property that contains the value of the folder to delete.
sInstallDirectory = Session.Property("CustomActionData")
' MsgBox "The Install Dir is: " & sInstallDirectory, vbInformation
' Make sure there is a trailing backslash at the end of the path
If Mid(sInstallDirectory, Len(sInstallDirectory), 1) <> "\" Then
sInstallDirectory = sInstallDirectory & "\"
End If
' MsgBox "The Install Dir is:" & sInstallDirectory, vbInformation
Dim objFSO
Dim oFolder
' Just to test, set the folder, under the INSTALLDIR to verify the deletion works. Will later be the entire customactiondata property.
oFolder = sInstallDirectory & "liferay-portal-6.0.1\tomcat-6.0.26\webapps\SAMServer-0.1.0-SNAPSHOT"
' MsgBox "The folder to delete is:" & oFolder, vbInformation
Set objFSO = CreateObject ("Scripting.FileSystemObject")
' If the folder exists then have it deleted.
If (objFSO.FolderExists(oFolder)) Then
' MsgBox "The folder " & oFolder & " exists so now to delete it.", vbInformation
objFSO.DeleteFolder oFolder, true
' MsgBox "The folder " & oFolder & " should now be deleted.", vbInformation
Else
' MsgBox "The folder: " & oFolder & " does not exists.", vbInformation
End If
' ********************************************
What I do not understand is that it does find the folder. It does go into the If statement:
If (objFSO.FolderExists(oFolder)) Then
So if it can find the folder why does it not delete the folder?
I have a test install that have the exact same custom action and therefore I set it to delete the same folder and it works correctly. So either the folder is locked during uninstall and therefore it can not delete it, but give the bogus message about Path not found, or something else if failing and given this message.
So if anyone has any clues let me know.
Thanks,
' ********************************************
Dim sInstallDirectory
' Get the property that contains the value of the folder to delete.
sInstallDirectory = Session.Property("CustomActionData")
' MsgBox "The Install Dir is: " & sInstallDirectory, vbInformation
' Make sure there is a trailing backslash at the end of the path
If Mid(sInstallDirectory, Len(sInstallDirectory), 1) <> "\" Then
sInstallDirectory = sInstallDirectory & "\"
End If
' MsgBox "The Install Dir is:" & sInstallDirectory, vbInformation
Dim objFSO
Dim oFolder
' Just to test, set the folder, under the INSTALLDIR to verify the deletion works. Will later be the entire customactiondata property.
oFolder = sInstallDirectory & "liferay-portal-6.0.1\tomcat-6.0.26\webapps\SAMServer-0.1.0-SNAPSHOT"
' MsgBox "The folder to delete is:" & oFolder, vbInformation
Set objFSO = CreateObject ("Scripting.FileSystemObject")
' If the folder exists then have it deleted.
If (objFSO.FolderExists(oFolder)) Then
' MsgBox "The folder " & oFolder & " exists so now to delete it.", vbInformation
objFSO.DeleteFolder oFolder, true
' MsgBox "The folder " & oFolder & " should now be deleted.", vbInformation
Else
' MsgBox "The folder: " & oFolder & " does not exists.", vbInformation
End If
' ********************************************
What I do not understand is that it does find the folder. It does go into the If statement:
If (objFSO.FolderExists(oFolder)) Then
So if it can find the folder why does it not delete the folder?
I have a test install that have the exact same custom action and therefore I set it to delete the same folder and it works correctly. So either the folder is locked during uninstall and therefore it can not delete it, but give the bogus message about Path not found, or something else if failing and given this message.
So if anyone has any clues let me know.
Thanks,
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Dec 06, 2010
11:43 AM
I ran the script and when I had a trailing backslash on my test folder path, it failed. When I removed it, it removed the folder without error.
It's kind of strange, because when I was working with vbscript quite a bit a while back, I thought the general rule when dealing with folders was to always include the trailing backslash.
Try getting rid of that in your path and see if that helps...
It's kind of strange, because when I was working with vbscript quite a bit a while back, I thought the general rule when dealing with folders was to always include the trailing backslash.
Try getting rid of that in your path and see if that helps...