Is this a practical use of a service? - service

I need to run an application which processes hooks in background. The problem is that I have to start it automatically on systemstart as administrator. I've tried to use the windows task scheduler but on some systems it does not start the program as administrator which causes strange behaviours.
I've never written an windows service but would that be a solution to create windows service? And if yes: Does it start automatically as administrator on systemstart? How can i communicate with the service from an configuration program? And as last question: If I am right, I need to install a service through an installer like a msi-package. How would you create such a msi-package. Visual Studio 2012 does not support that anymore.
It would be very nice if someone could help me. Sorry for my bad English but I am giving my best. If you don't understand some parts of my question, just ask me.

1) Yes, this sounds a lot like you should write a service.
2) If you configure it so, by default they start with a special service account.
3) You can find a lot of good information about communicating with a service here: How to communicate with a windows service from an application that interacts with the desktop?
4) You don't have to. Do you use C# for example? You can then make use of a nice library called TopShelf to write your service.

Related

Any Idea how to create a windows application and its windows service? Like antivirus. .NET

I need to create a window application that runs through a service as well as the antivirus that have their service and application, I need to send error messages to the user, I have the service but I do not know how to send error messages. I do not know how to create antivirus, if someone has any idea how to do that, I'll be grateful
Not sure if this will help and how it will help but posting this as answer to give a direction for your searches.Google - creating windows application as service
Above google search gives ways to setup a program as service
How to Run Any Program as a Background Service in Windows
Walkthrough: Creating a Windows Service Application in the Component Designer

Automated deployment of web site

I'm planning to do an automated deployment of a website,but im kind of stuck at this moment. I have looked at MS-Deploy, it got all the functions for deploying Website. I have a created a Web application package (.ZIP file) and I tested this on my local machine it is deploying website i.e
Create Web application under default website
Publishing files in c:\inetpub\wwwroot directory
Set ACLs on directories,etc
But i want to achieve few more extra steps for example:
Check whether Web application exists in Default Website, if not
create a Web application
Check whether Application pool exists, if not create a App pool
(given name) with a specific credentials and Assign App-pool to Web
application
Before it deploys take a backup copy of existing Web application (IF
exists)
publish offline page (app_offline.htm)
publishing the files to application directory
Replace the AppSettings section(in web.config file) to with actual values
Encrypt Web.config connection string
If there is any error whilst installing web application, rollback the web application to its previous version
The question is whether can i achieve all these functions via MS-Deploy or do i need to write any script, please suggest me what scripting language should i use
Please let me know if you need more information.
Thanks in advance
I'm not an expert on this topic but have been doing a bit of research on automated deployment with MSDeploy lately, and think I can offer the following;
This is default behaviour if you use the iisApp provider.
I know you can do this with the appPoolConfig provider, but I'm unsure as to how you would run this and #1 together as part of the same package. Perhaps as part of a pre- or post-sync command?
This is standard in v3, as long as it's set up on the server. Not used it myself, but read this anyway.
Fiddly. Not supported in MSDeploy, but you can vote for it if you want. Also, check out this SO answer (and also worth checking out PackageWeb, but the same answers' author).
Not sure I follow. This is done as part of a successful deployment, surely?
Use web.config transforms and optionally the aforementioned PackageWeb for a neat way to do this. Also check out Web Publish Profiles.
Difficult. My understanding is that the encryption is based on the machine.config, so you'd either have to run a post-sync script which would run some sort of remote Powershell script on the remote server to encrypt the web.config using aspnet_regiis, or you'd have to encrypt the config as part of your build process and then muck about with custom keys and the RSA provider (some info here).
I hope that helps. As I said, I'm no expert, so happy to be corrected by those more knowledgeable. Maybe also worth mentioning that MSDeploy is a lot more powerful if you use it via the command-line rather than creating packages from VS, although there is a bit of a learning curve to go with it.

Best practice deploying windows service

I'm looking for best practice in continuous delivery of windows services.
Currently we hava a set of powershell scripts that unintall, reboot, install updates but error handling is tricky. We are reviewing System center but are there any other options available for deploying a windows service?
We've been using Presto since Dec 2011, and have done over 1,000 deployments. Most of what we deploy are Windows services.
What's nice is that we set up our apps and servers in Presto, then we can repeatedly deploy, to any server (or multiple servers at once), by just hitting a button. Presto will copy our official release binaries, update all of the items in our app config files, create and start the service, etc...
So, if you have an application that has 30 manual steps to deploying it, you can enter these steps in Presto, then it's done automatically for you after that.
It's worth a look: http://presto.codeplex.com/
Your most basic and generally accepted best option comes from this thread, which basically links to a Microsoft support article on creating an installer for the windows service.

Can you write Windows services in Powershell

I have written a program in PowerShell that loops and checks stuff.
I would like to convert this into a Windows service.
I've created a Windows service (in Admin->Services) but I can't start it.
I'm pretty sure I'm missing the proper interface that the system needs to call into in order to start/stop/pause/etc the service.
I can find plenty of examples when it comes to doing it in VB/C#/MS-lang but nothing about how to do it using PowerShell. Is there any documentation (or preferably code examples) out there to help with this?
There are a few items at issue here:
Are you sure that you really need a service? I agree with the comments about using the scheduler for running periodic tasks. The scheduler can start tasks as Administrator.
Services call a special set of APIs to communicate with the Service Control Manager, so an ordinary program can't be used directly.
The Service Control Manager uses CreateProcessAsUser to start the service process, so you need to point the SCM to an executable binary, as opposed to a script.
If you can't use the scheduler (though I strongly encourage you to try), I suppose that you could write an executable binary that acts as a service. It would then execute PowerShell and your script on your behalf. I'm thinking something like the srvany program that used to be included with the Windows Server 2003 Resource Kit could bootstrap the service for you.
If you absolutly want to execute your PowerShell code into a service, I think you can write a C# service wrapper for PowerShell code.
You found examples of how to create a service with C#, and it's simple to call Powershell from C#. So I'am surprised that as small SrvAny oriented PowerShell does not exists yet.
My advice here, you better rewrite your code in C# as a service.
You can use the Compile Script into Service option of PowerGUI: http://documents.software.dell.com/DOC144271
I think what you are looking for is SrvAny.exe from Microsoft (I don't know that they support it any longer, but it has been around in the Windows 2000 Resource Kit for years. It will essentially turn just about any executable (.exe, .cmd, etc...) into a service. I have VBScripts running as quasi-services using Srvany.exe and it works on Windows 2003 and Windows 2008 (even 64 bit). It is a little limited in that it does not provide 100% service functionality (stopping a running script may be difficult) but if you now a bit about programming and the Windows environment you can adapt it to work pretty well (i.e. it will launch the program after server Restart/Startup as you would likely need from a service. There is some documentation with SrvAny.exe (although it can be a little obtuse and difficult to find). It is however Free and built for Windows so it should work for you.
I agree for simplicity that the Scheduled Task idea is worth thinking about as it is even more simplistic that srvany.exe
http://www.firedaemon.com/
Will allows you start littery anything as a service. There are also free alternatives to this application, that does the same.

Running JBoss in Windows Azure

I have found an example of running Tomcat in Windows Azure, but JBoss seems to be a bit trickier. Has anyone succeeded in running JBoss in Windows Azure, and if so, what should I do to get it running?
I would like to know if JBoss can be run in a worker role, not the VM role which is currently in beta.
I'd recommend trying it and asking questions as you get roadblocked. Most "does this run in Azure" questions are answered with "yes", but full-fledged examples and guides are going to be sparse as the platform is very new. So be the guy who writes it :)
You have two options with something like this:
1.) Run a worker role that invokes and runs similar to a windows service. (most tomcat on azure guides approach this way)
2.) Use a Azure Startup task to install, configure, start jBoss as a windows service and/or on top of tomcat
With the addition of full-trust, startup tasks, RDP, and eventually even VMrole .. anything that can run on a Windows 2008 server can run on Azure. So try installing on a Windows box, document those steps, then 1 by 1, figure out the "azure way" to accomplish those tasks. Approached this way, the initial setup will likely be pretty simple. From there, you'll learn a lot about Azure's offerings and can probably even make some changes to better leverage the platform for JBoss needs.
Once you get up there and have issues, ask away and you're more likely to find direct answers by the audience of MVPs, Azure team members, and cloud geeks here vs just a generic "have you done this" answer.