none
.Net service uninstalling itself - how? RRS feed

  • Question

  • I have a .net Windows service which I install using the InstallUtil program.  My service is able to receive network messages, and upon receiving an "uninstall" message I'd like the service to stop and uninstall itself.  I have tried the following with not much success:

    dim executeCmd As String
    
    executeCmd = "C:\WINDOWS\microsoft.net\Framework\v2.0.50727\InstallUtil.exe /u D:\Program Files\myService\myService.exe"
    
    Process.Start("cmd.exe", "/c " & executeCmd)
    
    
    I am not sure, but I am guessing i am running into the security issues of a service interacting with windows...

    Any ideas how to go about doing this?  Thanks.
    • Edited by Heems Wednesday, December 9, 2009 5:49 PM
    Wednesday, December 9, 2009 5:18 PM

Answers

  • i got it going. Silly quotes.
    Process.Start("C:\WINDOWS\microsoft.net\Framework\v2.0.50727\InstallUtil.exe", "/u ""D:\Program Files\myService\myService.exe""")
    The only gripe I have is that no exception is thrown.  But that's for another day perhaps.
    • Marked as answer by Heems Wednesday, December 9, 2009 6:59 PM
    Wednesday, December 9, 2009 6:59 PM

All replies

  • Just out of curiosity, what are you needing this for?  It sounds a little fishy.
    Coding Light - Illuminated Ideas and Algorithms in Software
    Coding Light WikiLinkedInForumsBrowser
    Wednesday, December 9, 2009 5:19 PM
    Moderator
  • Well, the business reason is that once a client leaves, we'd like to uninstall our program (windows service).  The service already communicates with our backend, so we want to enhance our capabilities by remotely removing our windows service on a bunch of machines rather than going maching by machine, and or some other windows scritped way.  Nothing fishy there (i hope).  What are you thinking about that's seems fishy?



    Ps: thinking that the cmd.exe was the issue, I even tried:

    Process.Start("C:\WINDOWS\microsoft.net\Framework\v2.0.50727\InstallUtil.exe", "/u D:\Program Files\myService\myService.exe")
    - the behavior is the same.  No error/exception.  The commands seem to just get ignored.
    Wednesday, December 9, 2009 5:36 PM
  • i got it going. Silly quotes.
    Process.Start("C:\WINDOWS\microsoft.net\Framework\v2.0.50727\InstallUtil.exe", "/u ""D:\Program Files\myService\myService.exe""")
    The only gripe I have is that no exception is thrown.  But that's for another day perhaps.
    • Marked as answer by Heems Wednesday, December 9, 2009 6:59 PM
    Wednesday, December 9, 2009 6:59 PM