Maniac
Posts: 12
Joined: Mon Mar 21, 2005 2:28 pm

VBS Custom Action - Session Property

Might be a dumb question, but maybe u can help me..

It's been a while since i had to code something in vbs, that's why i have some problems with it now..

Code: Select all

Function Main
   Dim fso
   Dim filespec 
   Set filespec = Session.Property("CustomActionData")
   Set fso = CreateObject("Scripting.FileSystemObject")
   fso.DeleteFolder filespec,true
End Function
I cant acess the session property, because i always get an 424 (Object required) error..

what am i doing wrong?
I often read about accessing the session properties in this forum, and i think i did everything like described...
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

There is an error in your script.

Code: Select all

Set filespec = Session.Property("CustomActionData")
should be

Code: Select all

filespec = Session.Property("CustomActionData")
as the Set statement is used for assigning an object reference.

Also, to successfully access a session property the custom action should be of "Immediate execution" type.

Of course the "CustomActionData" property should refer to a absolute, existing path. If the path does not exists the script will also return an error code. To cover this case you could select the "Synchronous execution, ignore return code" option.

Hope this helps.

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
Maniac
Posts: 12
Joined: Mon Mar 21, 2005 2:28 pm

Thanks, that worked fine..
But i have another scripting problem, that seems to be installer related:

Im using this line to remove the folder i got back from installer:

Code: Select all

fso.DeleteFolder filespec,true
But i always get a Path not Found error.
Im trying to remove it during the InstallFinalize Action.
I tried to output filespec and it is set correctly.
When I watch with the filemonitor I can that the installer opens and closes the folder successfully, but i get the Path no Found error....

The i thought maybe the installer locks the folder, but if i use a similar script (with a hardcoded path) which i start by my self during the InstallFinalize (that means, not as a custom action) it deletes the folder successfully...

Then I thought it would be maybe a permission problem, and tried to run a script as a user who has not the correct permissions, but then i get an Access denied error - the same is if i lock the folder by opening a file in it, and then trying to delete it.


Well.. hopefully you can help me - wasn't able to find any solution..

*edit*
forgot the mention the following:
If I try to create a folder using the path i get from the installer, it says that the file allready exists... So it says first i cant create it because it exists, and the i cant delete it because it doesnt exists..
And the funny part is that the filemon says the installer knows that it DOES exist :roll:
I hate it when software is lying to me :shock:
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

We cannot reproduce this so we are not sure what the problem might be. To figure out your problem we would need to take a look at the way your project is organized.

Could you please send your AIP file (or a similar simpler one, that reproduces the problem) and the script(s) you are using to support at advancedinstaller dot com ? We can then analyze them and see what the problem is.

All the best,
Mihai
Last edited by Mike on Tue Oct 25, 2005 8:15 am, edited 1 time in total.
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

The DeleteFolder method returns the "Path not found" error because the property giving the folder name contains a backslash at the end.

E.g. "c:\Program Files\Folder\"

This is not a valid argument for the method, as it requires the name of the folder to be last, with no backslashes.

So, the solution is to remove this backslash:

Code: Select all

filespec = Session.Property("CustomActionData")
filespec = Left (filespec, Len(filespec) - 1)
before calling the method.

All the best,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
Maniac
Posts: 12
Joined: Mon Mar 21, 2005 2:28 pm

Great! That did it!

Thanks a lot, Mike!
I wish every Software distributer would have such support :shock:

Return to “Common Problems”