cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Adam13531
Level 4

Figuring out which components are being uninstalled

I have a Basic MSI project in which I have several features that can be installed. At uninstall time, I need to call one of my executables with a certain directory as a command line argument, but the directory is based on what is being uninstalled.

I currently have a Custom Action that calls my executable (when 'REMOVE="ALL"') and has the [INSTALLDIR] as the argument, but this won't cut it anymore.

Is there a way to specify something like 'REMOVE='FEATURE1'"?
Labels (1)
0 Kudos
(14) Replies
Adam13531
Level 4

Is there a way to achieve this functionality (a CustomAction's '&Feature=2' condition) through InstallScript? I want to check and see what components are being installed and uninstalled and then pass in directories accordingly.
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

There's always the option to call MsiEvaluateCondition. Just beware that what it returns is not a plain TRUE/FALSE...
0 Kudos
Gvarma
Level 7

Adam13531 wrote:
Is there a way to achieve this functionality (a CustomAction's '&Feature=2' condition) through InstallScript? I want to check and see what components are being installed and uninstalled and then pass in directories accordingly.


huh... you could easily mark the component that you dont want to "Uninstall" as permanent this way, when you uninstall your application the components marked as permanent wudnt be uninstalled.


What exactly is your situation when it comes to uninstalling your product...do you need to determined what components needs to be uninstalled on the fly?

HTH
0 Kudos
Adam13531
Level 4

Gvarma wrote:
huh... you could easily mark the component that you dont want to "Uninstall" as permanent this way, when you uninstall your application the components marked as permanent wudnt be uninstalled.


What exactly is your situation when it comes to uninstalling your product...do you need to determined what components needs to be uninstalled on the fly?

HTH


When I uninstall, I want to save all files with a certain extension in every folder (in addition to saving some other folders), and I didn't know an easy way to make InstallShield remove everything except what I specify. What I'm doing now is passing in the directories of whatever should be removed to a program that will delete all files that don't have the extension I mentioned earlier. It also saves the folders I need.

It's very unwieldy and I'd like to change it, but I am sort of lost when it comes to using InstallShield, so I feel as though it would introduce another problem if I found a fix. A while ago I tried to find a way to install Windows services through InstallShield, but I didn't find anything, so I am using batch files to call installutil on the components that I am [un]installing.

Do you have any suggestions?
0 Kudos
Gvarma
Level 7

Adam13531 wrote:
When I uninstall, I want to save all files with a certain extension in every folder (in addition to saving some other folders), and I didn't know an easy way to make InstallShield remove everything except what I specify. What I'm doing now is passing in the directories of whatever should be removed to a program that will delete all files that don't have the extension I mentioned earlier. It also saves the folders I need.

It's very unwieldy and I'd like to change it, but I am sort of lost when it comes to using InstallShield, so I feel as though it would introduce another problem if I found a fix. A while ago I tried to find a way to install Windows services through InstallShield, but I didn't find anything, so I am using batch files to call installutil on the components that I am [un]installing.

Do you have any suggestions?


There are different ways you can achive this

for no 1.

You could create Compoments and mark them as permanent (as i suggested before), you could very easily to that by just going to the Property of Component and selecting "permanent" as yes, under the component include ONLY those files that do not need to be deleted upon uninstallation, then create another component (dont mark it as Permanent) and include only those files that needs to be deleted upon unisntall. Yes you will have to create 2 components for same destination folder, but it solves the problem within the constraints of MSI.

As far as creating services goes, it is also very simple, you could create a Service component (Or in setup design create a feature then right mouse click and select Component Wizard and follow the instruction for creating NT services).

HTH
0 Kudos
Adam13531
Level 4

Yes you will have to create 2 components for same destination folder, but it solves the problem within the constraints of MSI.


I had been adding folders through the Project Assistant, so it was creating something like 20 components for each folder I added, and I thought it would be hard to maintain if you had to find each of the ambiguously named "AllOtherFiles" that you wanted to keep. I'll try adding files through the Installation Designer instead and then use your approach. Will I need to modify the Remove Table this way, or will everything be automatic?

in setup design create a feature then right mouse click and select Component Wizard and follow the instruction for creating NT services


I tried this earlier and it did not seem to produce the same results as using installutil on my executable, even though it would correctly add my service to the list of services. I will try again when I test out the other changes that you proposed.

Thanks for the help!
0 Kudos
Not applicable

Instead of using the NTServices view or the ServiceXService InstallScript Functions, you can try marking the component containing the .NET Service you wish to install's .NET Installer Class property to "Yes". We will run InstallUtilLib.dll against your assembly.
0 Kudos
Gvarma
Level 7

Adam13531 wrote:
I had been adding folders through the Project Assistant, so it was creating something like 20 components for each folder I added, and I thought it would be hard to maintain if you had to find each of the ambiguously named "AllOtherFiles" that you wanted to keep. I'll try adding files through the Installation Designer instead and then use your approach. Will I need to modify the Remove Table this way, or will everything be automatic?



I tried this earlier and it did not seem to produce the same results as using installutil on my executable, even though it would correctly add my service to the list of services. I will try again when I test out the other changes that you proposed.

Thanks for the help!


No you dont have to modify remove table at all, the install/uninstall will be automatic. I have never used Project Asistant but I do agree with you on maintainence part.

I dont think you would need to go InstallUtil path, I have used same method consistently for 4 different services in my project without any problems.

HTH
0 Kudos
Not applicable

While it's possible to install it via the NTServices view, some assemblies may not install correctly that way. Generally, we suggest using the MSI Tables for Service installation and avoid Installer Classes where possible; however, sometimes there is no way to get the tables to install your service correctly.
0 Kudos
Adam13531
Level 4

While it's possible to install it via the NTServices view, some assemblies may not install correctly that way. Generally, we suggest using the MSI Tables for Service installation and avoid Installer Classes where possible; however, sometimes there is no way to get the tables to install your service correctly.


I'm still hopeful that I can get my installer working with the MSI tables, but I keep getting Error 1001. It used to say that the service already existed, but now it's saying "Unable to get installer types in the 'TestService.exe' assembly. --> Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information." I currently have two components set up for the TestService (one with all the files, one with just the .exe that is set to install/uninstall the service). I also set ".NET Installer Class" to "Yes" as you suggested.

It would be a lot easier to just use these tables, so is there something I'm doing wrong? I don't know where to find the LoaderExceptions property to figure out anything more about the error.
0 Kudos
Adam13531
Level 4

Does anyone know how to fix Error 1001 in this case? All the things I've found on the error through the Acresso Knowledge Base contain different messages and information regarding "Error 1001." I'm also very new to .NET so I'm not sure if there is a difference between InstallUtilLib.dll and installutil.exe in what their requirements are.
0 Kudos
Adam13531
Level 4

I am still having this problem and I'd like to avoid using batch files. Can anyone help or should I post a new topic about the error?
0 Kudos
Adam13531
Level 4

Okay, so I figured out why I was getting Error 1001 — something was trying to install my service twice somehow. I removed the "Install NT Services" event from the service component to test, and it still installed, even though there are no custom actions, no "Install NT Services" events left, and nothing in the ServiceInstall table. EDIT1: I figured out why it was being installed at least; when ".NET Installer class" is set to 'yes' then it will install.

It is installing correctly and I'm glad that it finally works, but it won't uninstall at all, and also it will give me Error 1001 again when I try to reinstall after uninstalling (because the service still exists!). EDIT2: I solved this second problem too; I set "Install Stop" and "Install Delete" to 'yes' in "Control NT Services", but it seems to ignore "Uninstall Stop" and "Uninstall Delete".

How do I get my service to uninstall correctly, and how can I prevent Error 1001 from showing up? This is important since I will be leaving this company soon and I need to finish the installer.

EDIT3: It appears as though creating a new Basic MSI project and doing everything exactly the same as what I was doing before now worked. I made a component, made it a .NET installer class, associated a "Control NT Services" event with it, and it installed and uninstalled just fine. I suppose it took me long enough to come to this solution!
0 Kudos