uninstall WindowsService option

Richnl

Well-known member
Joined
Mar 20, 2007
Messages
93
Programming Experience
Beginner
A Question here,

Is there an equivalent for the uninstall application option provided with the code below regarding windows service
Because it doesn't recognize keywords as "application" and "close"

Also, while I am at it, how can I at it to a specific folder in the
ProgramsStartFolder.
The issue is that I want to let the user have the option to install/uninstall the WindowsService. The WindowsService is in a separate setup package because when I had it in the application setup the uninstall option for the application would remove the WindowsService also what let to an IO exception. So my solution then is to have a checkbox connected with a vbScript to run the second setup. I hope that will work!

Long story, but that's why I need another uninstall option placed in the same folder as the application, if possible?
Also, is it possible to do a silent install for the second setup without any user interaction, because that would be anoying?
Another thing I found out is that the code beneath doesn't work if you have two primary outputs in the setup.
Is there a workaround for that or am I going to end up with three setups?


VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] arguments [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]() = Environment.GetCommandLineArgs()[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] argument [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] argument [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] arguments[/SIZE]
[SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] argument.Split([/SIZE][SIZE=2][COLOR=#a31515]"="[/COLOR][/SIZE][SIZE=2])(0).ToLower = [/SIZE][SIZE=2][COLOR=#a31515]"/u"[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] guid [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = argument.Split([/SIZE][SIZE=2][COLOR=#a31515]"="[/COLOR][/SIZE][SIZE=2])(1)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] path [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = Environment.GetFolderPath(Environment.SpecialFolder.System)[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] si [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] ProcessStartInfo(path & [/SIZE][SIZE=2][COLOR=#a31515]"\msiexec.exe"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515]"/i "[/COLOR][/SIZE][SIZE=2] & guid)[/SIZE]
[SIZE=2]Process.Start(si)[/SIZE]
[SIZE=2]Close()[/SIZE]
[SIZE=2]Application.Exit()[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]

Thanks in adv, Richard
 
Last edited:
I think the IO exception could be happening because you try to uninstall the application files while the service app is still installed/running as service. There are 2 steps to deploying a service app, first the service.exe is installed/copied to install path, then the service.exe is installed as service. When uninstalling the service app must first be uninstall as service before the files are uninstalled/removed. The MSI installer/setup project copies the files, then usually a custom action is used to install the service, see http://www.vbdotnetforums.com/showpost.php?p=36165&postcount=7
 
thank you

I did see that post!

I got it working, thats one down

Do you perhaps have a solution for the uninstall of the APP if it contains two primary outputs
( the main application and the server/client project) with one uninstall file.
I think that won't work, but my knowledge is still limited. (the installer gets confused now and does nothing)
 
Last edited:
The setup may include primary output for many projects within the solution, uninstalling will remove them all. With proper actions for service as you are informed there is no problem. There is no custom installer code necessary for this, also the setup project removes the main folder upon uninstall so you don't need code for this also.
 
It doesn't remove the main folder in my case!

I think you mean, removes everything from configuration>Software
Thats true!

I meant that I want to include an uninstall file so you won't have to go there. See post

I did an uninstall again, and I get the same IO error again on the service part.
Seems like the installer removes files before the custom action can get to it, or something like that.
Then my CPU go's to 100 % and I have to kill the computer again?
 
Last edited:
I found the answer for the error
I had another custom action that I had to move up in the hiearchie

It diddn't cleanup the folders, it actually leaves the install state behind in the folder?
 
Back
Top