Video Screencast Help
Search Video Help Close Back
to help
New in the Rewards Catalog: Vouchers for "Symantec Technical Specialist" and "Symantec Certified Specialist" exams.

Running SQL script when REMOVE/Uninstall

Updated: 12 Jun 2010 | 14 comments
Katrien's picture
0 0 Votes
Login to vote

Hi,

Apologies if this question has been posed previously, I cannot find it via "Search" but simply point me to the solution if so ...

I am desparately looking for a solution for the following problem.

1. In the Install I run a few SQL Scripts that create a database
2. In the uninstall I want to run a script that will Drop this database using another SQL script.
3. I tried editing the Execute Immediate script page and Execute Deferred page but I cannot get it to work.
4. I edited the Execute immediate like this: 

If REMOVE~=ALL Then
      Set Property WiseSqlCallID2 ......
End

Where the property points to a SQL script, similarly to how the scripts are defined in the install part, the difference is the REMOVE condition.

5. In the Execute deferred I call the action like this:

If REMOVE~=ALL Then
     Call DLL from ...
End

Again this is similar to how the install scripts are called, the difference is the REMOVE condition.

Anyone any ideas? The uninstall runs, but the uninstall SQL script is not executed.

Thanks in advance!!!! 
Katrien

discussion Filed Under:

Comments

EdT's picture
27
Nov
2009
0 Votes 0
Login to vote

Try If REMOVE="ALL"

Try
If REMOVE="ALL" Then....

(There must be double quotes around the "ALL")

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

VBScab's picture
30
Nov
2009
0 Votes 0
Login to vote

If REMOVE~="ALL" Then....

...The addition of '~' avoids the need for the user to specify "ALL" in all upper-case. The 'REMOVE' part must always be in all upper-case, obviously.

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

Katrien's picture
30
Nov
2009
0 Votes 0
Login to vote

I have entered it as

I have entered it as REMOVE~="All", but still not working. Anyways, it does seem to "go into" the if statement because in the log I can see that it sets the property etcetera. Also, in the log I can see an error message saying that it cannot establish the SQL connection.

Anyone any idea about why the SQL connection cannot be established in the uninstall? Do I need to specify somewhere that on REMOVE the connection must be configured? If so, where? 

Thanks,
Katrien

VBScab's picture
30
Nov
2009
0 Votes 0
Login to vote

Clearly...

...the connection to the d/b needs to be defined, unless you have somehow conferred psychic powers on your package. I figure one of the creation scripts has to contain the connection details. Use those.

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

Katrien's picture
30
Nov
2009
0 Votes 0
Login to vote

When I add the sql scripts in

When I add the sql scripts in WISE I use the sql connection properties as defined in the gui window there. In the MSI script I can see this translates to a statement like this:

Set Property WiseSqlCallID2 .... DRIVER={Sql Server};SERVER=(local); ...

(see also my very first post).

I import the uninstall script in the same way as I import the install script. The only difference is that in the MSI script editor I make some changes in the execute immediate and execute deferred. Please see my first post. So, I don't have psychic powers ...

VBScab's picture
30
Nov
2009
0 Votes 0
Login to vote

Presumably...

...you've run the uninstall SQL script outside of the MSI and proved that it does the job?

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

Katrien's picture
30
Nov
2009
0 Votes 0
Login to vote

Yes

I've done that indeed. And it works.

So perhaps I can rephrase my question.

I have a sql script that runs fine, I added it using the "SQL scripts" GUI in WISE. I would like this script to run on 'remove', not on 'install'. So what I've done is edit the condition to set the property and call the script in respectively Execute Immediate and Execute Deferred. I edited the condition from:

(!Complete = 2 AND &Complete > 2)

To

(REMOVE~="ALL")

But it doesn't work.

Can someome let me know if they've managed to run a sql script on the uninstall or remove events? And if so, how did you do this.

Thanks,
Katrien

AngelD's picture
30
Nov
2009
0 Votes 0
Login to vote

If the connection requires

If the connection requires authentication you'll need to pass that.
If you run the custom action in deferred execution then you would need to make sure the local system account has the correct credentials to make a valid connection.

Katrien's picture
02
Dec
2009
0 Votes 0
Login to vote

Ok, I understand that. But

Ok, I understand that. But that has nothing to do with my problem - in my opinion.

It works fine when I use the constraint: (!Complete = 2 AND &Complete > 2)

It does not work when I use the constraint: (REMOVE~="ALL")

That's what is the problem. So I need to configure something on the remove event that is configured on the install event. But what? 

Anyone an idea? 

VBScab's picture
02
Dec
2009
0 Votes 0
Login to vote

?

What 'install/remove' event? There are no such things.

I'm willing to bet that this is a vendor MSI and contains "black box" calls to DLL functions, one of which sets up the SQL connection.

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

EdT's picture
02
Dec
2009
0 Votes 0
Login to vote

Where is your custom action sequenced?

Looking back over the thread, there are references to the uninstall custom action being placed in the immediate and the deferred sequences,  but there is no actual information on where in these sequences your CA is actually placed.
Since the REMOVE property is not set to "ALL" until the InstallValidate action, any CA sequenced before InstallValidate which tests the REMOVE property is not going to work correctly.
Examining a verbose log of the uninstall will give you information about the values assigned to properties, etc.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

Katrien's picture
10
Dec
2009
0 Votes 0
Login to vote

I am really disappointed

I am really disappointed about not getting this to work. In InstallShield you can simply add a SQL Script and select "run on uninstall". You would think that this is something that is used often in database installations.

I am only using WISE in trial mode, but don't think I will buy the full version. It's too fiddly to get it to work.

VBScab's picture
10
Dec
2009
0 Votes 0
Login to vote

You're likely to find...

... that when selecting that option, all IS does is add the REMOVE~"ALL" condition to the CA. It just does it "behind the scenes".

IS has its own challenges, like its brain-dead presentation of Custom Actions (amongst other UI foibles). I also find its MSI compilation glacial, to say the least.

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

Katrien's picture
11
Dec
2009
0 Votes 0
Login to vote

Well, at least it works in

Well, at least it works in IS! And adding the condition to the CA doesn't work for me in WISE.