Install windows service without using InstallUtil or Setup Installation - windows

I would like to send a windows service program to our client that does not have InstallUtil (no rights to distribute) and this one will be multiple installations in the same machine.
I found something at this point: Inno Setup for Windows service?
But I am not clear how to:
add the InnoSetup script and where to add this script?
For the if and else: System.Environment.UserInteractive? if a service is not installed, then it will be going inside this if?
Thanks in advance.

I have provided a step-by-step solution for how to add command-line install/uninstall to your Windows service using C#. This solution lets you avoid requiring the use of InstallUtil.
How to make a .NET Windows Service start right after the installation?

You need to add an installer to your service setup project, and a custom action. This article will get you started.

Related

How to make a program run at startup (as admin) with WiX on Windows 10

Can someone tell me how to properly install this program to run with admin privileges at startup on Windows 10 using WiX?
All the help I've seen via Google has been old ones saying to use the Startup folder. Now, although the Startup folder still seems to work, I don't think it's the preferred way to do it anymore.
I also need think the need to run as admin adds a wrinkle in the process.
I can see few ways to do it:
Set registry values using WIX:
in this case you should add your app install path to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run (x86) or HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run (x64). Problem is to get windows version. I guess it's possible to do by WIX (using few RegistryKey elements with condition) but I haven't tried.
Use custom action to set registry values: the same as previous, but using C#. Also in this case it will be easy to determine windows version and add your app to the right key.
Using custom actions and Task Scheduler. For example you can use this library to add task to run after startup.
Run cmd using WIX to set up Task Scheduler (or via custom actions). The same as previous but without any libs.
A program requesting or requiring admin is a function of the EXE not WiX. The EXE should be manifested to request elevation.
MSFT has said it is not a best practice to have things in startup request admin. It's a horrible user experience.
The better approach is to do what you said you do in your comment. Have a component running as a service that the non-priv UI can communicate with.

Installing services remotely

Is there a way to install services remotely, without necessarily resorting to .msi packages or full-blown installers? I'm currently using a method similar to the one discussed here:
How to install a windows service programmatically in C#?
to install a service locally, and it works fine. However, I also need to be able to do the same thing remotely. I appreciate any insight.
If you can copy the service binary (the exe file) to the destination computer you can install the service exactly in the same way as you do this locally. The only distinguish is that during the usage of OpenSCManager function (see http://msdn.microsoft.com/en-us/library/ms684323.aspx) you should use destination computer as the first parameter (lpMachineName) and in CreateService (see http://msdn.microsoft.com/en-us/library/ms682450.aspx) as a lpBinaryPathName you should place the path to your service exe how it looks like on the remote computer.
You can use sc.exe utility to do the installation (type" sc create /?" in the command prompt to receive help). The remote installation of the service which you can do with sc.exe you can implement with native Windows API like I short explain above.

inno setup install script and windows 7

any recommendations about those inno setup scripts so the compiled install run smoothly on windows 7?
Don't install anything to user-directories. Assume the installer will be run from a different account than the one that will use the installed application.
If you need to save user-specific stuff install it as a template to a shared location (ideally read-only to regular users, e.g. under {app}) and have your application copy it from there on first startup.
Don't create Quick Launch shortcuts
Oliver Giesen's suggestion is what I'm using, but it has a disadvantage... there seems to be no way to remove the {userappdata} folders for all users when uninstalling the program, meaning you can never do a clean uninstall/reinstall.
Inno Setup has full support for Windows 7. Just make sure to use the latest version of Inno Seup, preferably the Unicode edition.

Is there an official GUI way of installing and removing .Net services on Windows Server 2008?

Please read the whole question; I personally think that this is programming-related; if you think otherwise, then please migrate without down-voting.
I have found two different ways of installing a service:
http://www.wsinnovations.com/softeng/support/manualservice.html
as well as using http://msdn.microsoft.com/en-us/library/50614e95(VS.80).aspx
The reason why I ask for this is that I am trying to debug a service which is somehow supposed to update itself. It is not currently working, but I was told that this did work in the past.
I have been using the sc delete <servicename> command to remove the service (because it is shorter that way), while installing it with an installutil command. I hope this does not result in any side-effects; I would like to rule those out.
Ideally, it should be possible to install and uninstall services right from the screen which lets the user start and stop them, but such option is not does not exist unfortunately. I am looking for the next best thing, which is a GUI wrapper for installutil.exe
No - not in the way I believe you're thinking of. The GUI way would be as part of an MSI or other installer, which calls the same APIs as installutil does.
So what you could do is write an installer which can run silently, and then use that to install and uninstall.
You could create an installer using one of the many installation frameworks out there. I personally use WiX and there are a bunch of examples out there about how to write these sorts of things.
Maybe have a look here to get an impression of the underlying API: Install a .NET windows service without InstallUtil.exe

How to make a Win 32 App run as a Windows Service?

Our company just completed a Win 32 Application project, and we have a executable program and it works fine in Windows. Now we have to run it as a windows service under Network account. I am pretty new to Windows Service, so please advice, what should I do to transform this program to a Windows Service? Thank you!
If by "Win32 Application project" you mean "GUI program", then do not run that as a service. Otherwise, here's what you need to do:
Register a service control handler using RegisterServiceCtrlHandler as soon as your program starts. This is required so you can handle the start and stop events. If you do not do this the service manager will kill your process because it thinks it's not a real service.
If you have an installer, you can use the sc command to create the service. For example: sc create MyService binPath= "C:\PathToExe\MyService.exe" type= own start= auto.
Alternatively you can call CreateService if you have code to do this.
If you mean that you want to run your application as a windows service, there is a utility in Windows Resource Kits. It's name is srvany.exe and you can find documentation about it here:
http://search.microsoft.com/search/results.aspx?st=b&View=en-us&s=1&c=0&qu=137890
Srvany.exe can be downloaded as part of Windows Server 2003 Resource Kit Tools here:
http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en
Srvany.exe is a fine, free solution (as described by alemjerus), but please check out AlwaysUp if you are working in a professional environment and need a robust/advanced feature set.
Good luck!

Resources