I am running the Spring-Boot application as a Windows service.I can see my services is listed in the MSCONFIG
I wanted to know how can I
Stop
Start
Delete
The Service.
You can't perform those operations from MSCONFIG. Use the services control panel application (services.msc) to start, stop and generally manage your service. Use the SC command line utility to delete your service ("SC DELETE service-name").
Related
I would like to start a Windows service ((as a daemon or ScheduledTask) on one of the clients in a small Active Directory domain for testing purposes only. The Windows service is Docker Desktop. Ideally, the service should start before a user logs in.
I am wondering what is the recommended approach for this procedure to start services properly and securely.
My approach would be the following: I would create a local user and then assign the service to that user using Task Scheduler. Would that be broadly the recommended approach or is there some kind of system user to entrust the task to?
Services are being managed using an NSIS installer. On uninstallation those services are stopped using net stop, because it is synchronous, then flagged for deletion using sc delete, as they do not have to be deleted immediately/synchronously.
Now I am wondering about the installation process. The order of calls is such:
net stop service1
net stop service2
sc config service1 depend=dependency1
sc config service2 depend=dependency2
sc start service1
sc start service2
Is there an intrinsic order to queries passed to sc? Are they worked through in the order sc is called (I assume they are not)? Are they being delegated to the respective service and queued there (this is what I hope for), e.g. whether service1 or service2 is stopped and configured first is ambiguous, but the sc config, sc start order is not? Is the order entirely ambiguous?
In addition I am curious to know what happens when mixing net and sc calls. Assume the following order:
net stop service
sc config service
net start service
Is it reasonable to assume that the service would likely be stopped, then started before any configuration occurred?
Supposedly the general question is, how to ensure proper service setup via concatenated sc/net calls. The required order:
Stop service (it may or may not exist on system)
Create service / conffigure service
Start service
Uninstallation is less pressing, because stopping services and flagging them for deletion is sufficient.
Mixing sc and net calls should not be a problem because it is the SCM (Service Control Manager) process that controls the services, other applications simply asks the SCM to perform a specific operation.
The documentation for the ChangeServiceConfig API function states that:
If the configuration is changed for a service that is running, with the exception of lpDisplayName, the changes do not take effect until the service is stopped.
This leads me to believe that a installer can use the following sequence:
Install/Configure --> Stop (synchronous) --> Start.
Performing "Stop --> Configure --> Start" is always going to have a race condition issue because another process might trigger a service start at the wrong time.
I am trying to deploy an ASP.NET application to IIS using Powershell (run by Ansible).
I want my application to be able to query the performance counters so I am adding it to the Performance Monitor Users using this Powershell script:
appPoolName=$args[0]
$group = [ADSI]"WinNT://$Env:ComputerName/Performance Monitor Users,group"
$ntAccount = New-Object System.Security.Principal.NTAccount("IIS AppPool\$appPoolName")
$strSID = $ntAccount.Translate([System.Security.Principal.SecurityIdentifier])
$user = [ADSI]"WinNT://$strSID"
$group.Add($user.Path)
It actually comes from another SO question: Add IIS AppPool\ASP.NET v4.0 to local windows group.
After the deployment, it can happen that the user is added to the group but the application still can't access the performance counters.
The script is run just before starting the App Pool and the application.
I have tried the following things, without success:
Restart the application
Restart the App Pool
Set AnonymousAuthentication to 'Application pool identity'
Deploy again
I have modified my deployment scripts in the following ways, without success:
Remove the user from the group before adding it
Restart the App Pool after adding the user. IIS actually complains ("The service cannot accept messages at this time").
Add the user to the group after starting the application
Add the user to the group at the beginning of the deploy (before stopping the application and pool)
The only way I have to solve my problem is to restart the machine. I would like to know if there is a better one!
If it is possible, I think making the App Pool user log off and back on would solve my problem. I haven't found how to do that (restarting or recycling the App Pool doesn't work).
The answer was a simple iisreset (in command line or Powershell).
I am having trouble when I have one Windows service try to install another Windows service.
Specifically, I have a TeamCity agent running tests for me on a Windows 2008 AWS instance. The tests are written in Java, which shell out to a .bat script to install a service (let's call it Service A), giving it a unique name each time.
The offending line is in the .bat script: sc create "%serviceName%" binPath= %binPath% DisplayName= "%serviceDisplayName:"=%" start= %serviceStartType%. I believe as long as the service name is unique that should work.
And indeed it does work if I run the tests manually on the command line, using an administrator account. Service A is installed, the test completes and Service A is uninstalled at the end.
I have tried running the TeamCity agent as LocalSystem, as Administrator, and as another user that is member of the administrators group. I have also tried disabling UAC completely.
Presumably the problem is access denied type errors, although that is not clear at this point. There are a few avenues to explore still, but it is a simple question really: are processes running as services forbidden from installing other services? Are there special things I have to do to configure the machine/ account to allow it to do this?
The point of the test it to install and use Service A, so workarounds are not relevant - Service A must be operated as a black box.
Thanks!
There are no restrictions on creating services with regards to how the creating process can execute, as long as the process has the appropriate permissions. That is to say, a process could be running as a service and create another service -- the only consideration here is the appropriate permission level.
The problem that often occurs with running batch scripts from within processes (as opposed to directly through user input on the command line) is that the environment expected isn't always the environment that is loaded. In this case, it appears that the env variables referred to in the batch script weren't properly set when running as a service, which of course then caused the service install failure. Correcting the environment loaded when the batch script is shelled out is the correct solution here.
I want to create a windows service to run an exe on start up.
Actually i am using mongodb.
Every time i need to start the mongod.exe at first to perform all operations.
Please give some suggestions to create a service to start this exe on start up.
A Windows service needs to communicate with Windows' service control manager.
I guess that mongodb does not support this out of the box.
So you either need to create a small service framework that starts mongodb or you can use something like srvany.exe (http://support.microsoft.com/kb/137890/en-us/).
Service Installation can be done with SC.EXE
MongoDB already runs as a service. Why aren't you installing it the usual way?
I got answer from this link.
Its working fine.
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/#mongodb-as-a-windows-service