Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. setup and unistall

setup and unistall

Scheduled Pinned Locked Moved C#
csharpquestionworkspace
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tomorrow_ft
    wrote on last edited by
    #1

    hi all, I wrote a service in c# and I prepared a setup to service but now I want to unistall if service install before and then install last setup how I do this?? thanks..

    C 1 Reply Last reply
    0
    • T tomorrow_ft

      hi all, I wrote a service in c# and I prepared a setup to service but now I want to unistall if service install before and then install last setup how I do this?? thanks..

      C Offline
      C Offline
      Calla
      wrote on last edited by
      #2

      So you want to do an upgrade?? I will assume you have used a VS Setup project for doing this. If you want your service to be updated and you use VS2008. Do the following: Add a custom action for Install, Commit, Rollback and Uninstall and add "Primary output..." of your service project. Add the Condition NOT PREVIOUSVERSIONSINSTALLED for Install and Commit. In your Setup-project choose RemovePreviousVersion: True and change the UpgradeCode and Version. IF you are using VS2005 you don't have to add the NOT PREVIOUSVERSIONSINSTALLED as a Condition. This was altered in VS2008. I also assumed that you added a ProjectInstaller to your service project :)

      T 2 Replies Last reply
      0
      • C Calla

        So you want to do an upgrade?? I will assume you have used a VS Setup project for doing this. If you want your service to be updated and you use VS2008. Do the following: Add a custom action for Install, Commit, Rollback and Uninstall and add "Primary output..." of your service project. Add the Condition NOT PREVIOUSVERSIONSINSTALLED for Install and Commit. In your Setup-project choose RemovePreviousVersion: True and change the UpgradeCode and Version. IF you are using VS2005 you don't have to add the NOT PREVIOUSVERSIONSINSTALLED as a Condition. This was altered in VS2008. I also assumed that you added a ProjectInstaller to your service project :)

        T Offline
        T Offline
        tomorrow_ft
        wrote on last edited by
        #3

        "Add the Condition NOT PREVIOUSVERSIONSINSTALLED for Install and Commit. In your Setup-project choose RemovePreviousVersion: True and change the UpgradeCode and Version" how I add NOT PREVIOUSVERSIONSINSTALLED condition and choose RemovePreviousVersion where is it??

        1 Reply Last reply
        0
        • C Calla

          So you want to do an upgrade?? I will assume you have used a VS Setup project for doing this. If you want your service to be updated and you use VS2008. Do the following: Add a custom action for Install, Commit, Rollback and Uninstall and add "Primary output..." of your service project. Add the Condition NOT PREVIOUSVERSIONSINSTALLED for Install and Commit. In your Setup-project choose RemovePreviousVersion: True and change the UpgradeCode and Version. IF you are using VS2005 you don't have to add the NOT PREVIOUSVERSIONSINSTALLED as a Condition. This was altered in VS2008. I also assumed that you added a ProjectInstaller to your service project :)

          T Offline
          T Offline
          tomorrow_ft
          wrote on last edited by
          #4

          I found them and I did them but it is not work I unistall service "sc delete servisname" from command prompt ,is it necessary tu use this command?

          C 1 Reply Last reply
          0
          • T tomorrow_ft

            I found them and I did them but it is not work I unistall service "sc delete servisname" from command prompt ,is it necessary tu use this command?

            C Offline
            C Offline
            Calla
            wrote on last edited by
            #5

            No not really. Just to make sure I understand your question correctly, is this your scenario: You have created a Windows Service (NT Service) and you have added a ProjectInstaller in that project. You added a Setup project to your solution to install your Windows Service. Now you want to make an upgrade of your Service, for instance upgrading from version 1.0 to 2.0. Then you should do the following: 1. Create a Custom action to your Setup project for Install, Commit, Rollback and Uninstall, adding the Project Output.. of your Windows Service. 2. Change RemovePreviousVersion from false to true. 3. Change the Version of your Setup project (i.e. from 1.0 to 2.0). 4. Change the UpgradeCode of your Setup project (I believe VS asks you if you want to change this when you change the Version). 5. If you are using VS 2008 (or 2010?), add the NOT PREVIOUSVERSIONSINSTALLED as a Condition. If you are using VS 2005, this is not necessary (Microsoft changed this behaviour between the 2005 and 2008 version of VS. This means that in 2008 the Service will not really be uninstalled in the Service Control Manager - only the binaries will we changed). I know i repeated myself a bit from my previous answer, but this is actually the only steps you need to go through to make it work. If it doesn't work - please provide the code in your ProjectInstaller class, because maybe something is missing there. Also provide any error messages displayed. You should not have to make any commands like "sc delete servisname" etc. All this should be taken care of by MSI.

            T 1 Reply Last reply
            0
            • C Calla

              No not really. Just to make sure I understand your question correctly, is this your scenario: You have created a Windows Service (NT Service) and you have added a ProjectInstaller in that project. You added a Setup project to your solution to install your Windows Service. Now you want to make an upgrade of your Service, for instance upgrading from version 1.0 to 2.0. Then you should do the following: 1. Create a Custom action to your Setup project for Install, Commit, Rollback and Uninstall, adding the Project Output.. of your Windows Service. 2. Change RemovePreviousVersion from false to true. 3. Change the Version of your Setup project (i.e. from 1.0 to 2.0). 4. Change the UpgradeCode of your Setup project (I believe VS asks you if you want to change this when you change the Version). 5. If you are using VS 2008 (or 2010?), add the NOT PREVIOUSVERSIONSINSTALLED as a Condition. If you are using VS 2005, this is not necessary (Microsoft changed this behaviour between the 2005 and 2008 version of VS. This means that in 2008 the Service will not really be uninstalled in the Service Control Manager - only the binaries will we changed). I know i repeated myself a bit from my previous answer, but this is actually the only steps you need to go through to make it work. If it doesn't work - please provide the code in your ProjectInstaller class, because maybe something is missing there. Also provide any error messages displayed. You should not have to make any commands like "sc delete servisname" etc. All this should be taken care of by MSI.

              T Offline
              T Offline
              tomorrow_ft
              wrote on last edited by
              #6

              thanks for your answers,you understand correctly my problem my projectinstaller class only like this: namespace SistemServis { [RunInstaller(true)] public partial class ProjectInstaller : Installer { public ProjectInstaller() { InitializeComponent(); } } I added aproject installer but I didn't add anything else. Do I have to write different things???

              C 1 Reply Last reply
              0
              • T tomorrow_ft

                thanks for your answers,you understand correctly my problem my projectinstaller class only like this: namespace SistemServis { [RunInstaller(true)] public partial class ProjectInstaller : Installer { public ProjectInstaller() { InitializeComponent(); } } I added aproject installer but I didn't add anything else. Do I have to write different things???

                C Offline
                C Offline
                Calla
                wrote on last edited by
                #7

                Okay, then that's your problem. You have to add code to the ProjectInstaller class that actually does the installation of your service. In your case it would look something like this (from MSDN example):

                namespace SistemServis
                {
                [RunInstaller(true)]
                public partial class ProjectInstaller : Installer
                {
                private ServiceInstaller serviceInstaller;
                private ServiceProcessInstaller processInstaller;

                  public ProjectInstaller()
                  {
                     InitializeComponent();
                     processInstaller = new ServiceProcessInstaller();
                     serviceInstaller = new ServiceInstaller();
                
                     processInstaller.Account = ServiceAccount.LocalSystem; //or the account you wish to use
                     serviceInstaller.StartType = ServiceStartMode.Manual; //or the mode you wish to use
                
                     serviceInstaller.ServiceName = "YourServiceName"; //name of your NT service
                     Installers.Add(serviceInstaller);
                     Installers.Add(processInstaller);
                  }
                

                }
                }

                Good luck!

                T 1 Reply Last reply
                0
                • C Calla

                  Okay, then that's your problem. You have to add code to the ProjectInstaller class that actually does the installation of your service. In your case it would look something like this (from MSDN example):

                  namespace SistemServis
                  {
                  [RunInstaller(true)]
                  public partial class ProjectInstaller : Installer
                  {
                  private ServiceInstaller serviceInstaller;
                  private ServiceProcessInstaller processInstaller;

                    public ProjectInstaller()
                    {
                       InitializeComponent();
                       processInstaller = new ServiceProcessInstaller();
                       serviceInstaller = new ServiceInstaller();
                  
                       processInstaller.Account = ServiceAccount.LocalSystem; //or the account you wish to use
                       serviceInstaller.StartType = ServiceStartMode.Manual; //or the mode you wish to use
                  
                       serviceInstaller.ServiceName = "YourServiceName"; //name of your NT service
                       Installers.Add(serviceInstaller);
                       Installers.Add(processInstaller);
                    }
                  

                  }
                  }

                  Good luck!

                  T Offline
                  T Offline
                  tomorrow_ft
                  wrote on last edited by
                  #8

                  :( nothing changed when I tried to install, service all times give this error: error 1001:the apperred system is still there.

                  C 1 Reply Last reply
                  0
                  • T tomorrow_ft

                    :( nothing changed when I tried to install, service all times give this error: error 1001:the apperred system is still there.

                    C Offline
                    C Offline
                    Calla
                    wrote on last edited by
                    #9

                    hmm.. that's odd. Could you make sure that your service is uninstalled when you run your "new" MSI (the one generated with the code I added), then make an install, change the version number (and upgrade code) and then perform an upgrade?

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups