I tried running the below command in administrator mode to install nginx as service
nssm install ztestservice "C:\Stack\nginx\nginx.exe"
nssm is installing the service but there is no reference to the application path in the registry. i.e. no parameters are set. When I try to start the service shows error "cant start service".
Please help.
I have been using nssm to run a php script. I find if you run just:
nssm install ztestservice
nssm will pop up a window that lets you set all the other parameters. Otherwise, you can set the parameters separately using the set command:
nssm set <servicename> <parameter> [<subparameter>] <value>
so:
nssm set ztestservice AppParameters "C:\Stack\nginx\nginx.exe"
However, watch out. On windows 2012r2 i'm experiencing an issue where it now hangs on the stop command so i'd watch out for that!
EDIT: You can also run nssm dump ztestservice' will also give you a list of the available parameters
EDIT2: (Will i ever stop editing this?)nssm edit ztestservice' to edit the service you just created, changing all params and having them set in the registry.
Related
I am using NSSM to create a service, however, after creation I need to set some parameters, such as AppDirectory, AppNoConsole, etc.
I am able to create the service using the GUI, but I want to do it via cmd, for which I have a batch file that goes like this:
nssm install MyService "%Java_Exe_Path%" "-Xmx1024M -classpath \bin\start.jar;\lib\*;. com.myapp.class.subclass start"
nssm set MyService AppDirectory "%DIR%"
nssm set MyService AppNoConsole 1
Thing is I am getting errors that read:
Can't open service! OpenService(): Access is denied.
Or
OpenService(): The specified service does not exist as an installed service.
Notes: When I run the cmd file I get asked for admin rights (guessing to run the install), but to edit (set) I am not being requested permissions, neither I get asked permissions if I run the set command directly via commandline (also getting an error of access denied).
Can anyone help?
Thanks!
Got the same problem, my solution is always run this script as an administrator:
How to request Administrator access inside a batch file
I'm trying to use the Non-Sucking Service Manager (NSSM) to create a service. Unfortunately, for whatever reason, NSSM won't play ball.
I'm trying to install the service using the following command:
nssm install "My Service" "C:\Program Files\Vendor\bin\windows\service-start.bat"
The service is successfully created. However, when I go to Services and Right-Click on "My Service" and view the properties the "Path to executable" field is set to the path of NSSM itself. In this case, 'C:\Program Files\nssm-2.24\win64\nssm.exe'.
I've attempted to change this using the following command:
nssm set "My Service" AppDirectory "C:\Program Files\Vendor\bin\windows\service-start.bat"
This doesn't make any difference and the executable path remains the same.
I'm trying to do this on Windows Server 2012 R2.
As CodeCaster mentioned, the 'Path to Executable' is correctly referring to nssm. Since nssm is a wrapper, you technically tell nssm to manage your service.
If you want to verify if your installed service actually refers to your service, you will need to check that in nssm instead. You can do so with below command:
nssm edit <servicename>
Here you can see what is configured for your service and you can do some extra configuration here as well.
I hope that clarifies things a bit.
NSSM is a wrapper which responds to SCM commands... which a batch file won't.
When registering the service, ...service-start.bat is configured as a commandline arguments to the NSSM executable.
I have to start, stop a jar in a flow
1. I have to stop it if it is already running and then start
2. All this is being worked in Udeploy.
3. I'm installing the jar using the below command.
java -jar jarname.jar
When I use sc query servicename, it says the service is not installed as a Windows service. So, I can check, stop and start if it is only a windows service.
How can I install this as a windows service with a servicename to identify ?
You can use nssm to install a jar as a Windows service. No installation of nssm is needed. Just place it somewhere on the system (preferably somewhere in your PATH) and run it.
Here is the command to execute as a batch:
nssm.exe install "(service-name)" "{java.exe path from jre}" "-jar
{jar-name-absolute-path}"
nssm.exe set "{service-name}" AppDirectory "{jar-path}"
Install a windows service: there is a util with Visual Studio: InstallUtil.exe.
If I have a service MyService.exe and want to install it on a windows 7 without Visual Studio on it, how can I install it?
One way is to use sc.exe, which is part of OS. Example:
sc create **ServiceName** start= auto binPath= "c:\mydir\myService.exe"
where binPath is exe file containing your service.
if you don't want start type = automatic then you can use net start and net stop command on command line of windows to start and stop service respectively.
You can try NSSM (Non-Sucking Service Manager) for the times the "sc" doesn't work quite as expected. http://nssm.cc
I had an service I built in Go not too long ago that I could not get to run under "sc", nssm worked perfectly.
you can find installUtil.exe at "C:\Windows\Microsoft.NET\Framework\v2.0.50727", launch from CMD prompt, and add the path to your service
Couldn't get NSSM to work on my W7. It always put its own path as the path to the program I put in the Path box. Had to go manual with the sc example above. That worked perfectly. To get a list of sc parameters, just execute sc. The two * preceeding the ServiceName will cause the ServiceName to appear at the top of the C:\Windows\System32\compmgmt.msc list. To remove a service, use sc delete ServiceName. You will have focus the list and use the Refresh menu item to see the change in compmgmt.msc.
i have installed mongodb on win32 and i am trying to run it as a service.
I have followed the instructions posted here: http://www.deltasdevelopers.com/post/Running-MongoDB-as-a-Windows-Service.aspx
but when when windows tries to 'load'/'run' the service there is a problem. I see the service under the services control banner constantly in the 'starting' state.
The result: the service is not started and windows is constantly trying to start it without success.
The instructions i have followed are:
At the command line
C:\mongodb\mongod -install
then
C:\mongodb\mongod -service
Then i modified the Win Registry Entry for the MongoDB Service by setting the ImagePath key to the value of C:\mongodb\mongodb.exe -service
Any advice? What am i doing wrong?
Just for future reference: running mongo as a windows service
Also lots of people seem to be saying: specify the whole path to the mongod.exe:
c:\mongo\mongod.exe --logpath "c:\mongo\logs\mongo.log" --logappend --dbpath "c:\mongo\data" --directoryperdb --install
Also if you're running Windows 7 don't forget to run the command window as an administrator.
I'd do it this way just cause I like to customize/organize things better:
Unzip mongo to where you want.
I like putting all the configuration in a file (my preference, since I didnt like default location of C:/data/db, and didn't like all the options as commandline params)...
Looks something like:
[C:\dev\mongodb\data\mongodb.conf]
dbpath = C:\dev\mongodb\data\db
logpath = C:\dev\mongodb\data\mongodb.log.txt
logappend = false
Then I put C:\dev\mongodb\bin in my Env Variable's PATH (so can call mongo.exe from any dir), but not needed...
Then on command line to install the Windows Service:
$ cd C:\dev\mongodb\bin
$ mongod.exe -f C:\dev\mongodb\data\mongodb.conf --install
It will create a Windows Service which if you want, can start manually via:
$ net start MongoDB
//Use qoutes if changed service name (via -serviceName to mongod --install), like: net start "Mongo DB"
Specifying several parameters at once is a good choice.
mongod
--install
to install as a service
--rest
to enable rest access to mongodb
–master
to set up mongodb instance as master.
–logpath
this is mandatory when you install mongodb as service
--dbpath
this too is mandatory for mongodb to run.
Here is a step by step guide describing the installation of MongoDB Service on Windows 7.
I have been faced similar issue. And i tried above solutions still have not get any result.
finally below code is solved my issue.
-> Command prompt open as administrator.
-> Copy and paste the below code after changing the proper bin and config path.
sc.exe create MongoDB binPath= "\"d:\MongoDB\bin\mongod.exe\" --service --config=\"d:\MongoDB\mongo.cfg\"" DisplayName= "MongoDB" start= "auto"
Happy Coding !!!!!!
Regardless of whether you're running as a service or not, you need to specify the --dbpath argument to mongod.exe.
Also, you shouldn't have to edit the registry. You can just issue the command like this:
C:\mongodb\mongod.exe --dbpath C:\data\db --install