0

I have created a simple batch file to start my redis node.

@echo off
start cmd.exe /k "cd C:\Users\cmguser\Desktop\7000 & redis-server ./redis.conf"

This batch file is working fine, if I am running it in cmd as administrator. I am creating this bat file as a windows service, through NSSM, but the service is giving following error: "windows could not start the service on local computer the service did not return an error." Referred this link.

Do I have to mentioned run as administrator in my batch file, or there is any other issue through above mentioned method?

Also I have tried creating service through following command but it threw the 1053 error :

sc create service_name binpath=C:\Users\user\Desktop\redis_config_7000  start= auto
Rohit Bagjani
  • 1,264
  • 2
  • 11
  • 14
  • I am not sure of your config. but you are calling `redis_config_7000` as a path, is this where your binary file aka batch file is located? – Gerhard May 30 '17 at 12:02
  • redis_config_7000 is just having minimum configuration to create a redis node. Yes, in this location, my batch file is located. – Rohit Bagjani May 30 '17 at 12:30
  • There are a number of solutions, many free, available. Try https://www.google.com/#q=run+batch+as+service – lit May 30 '17 at 17:23
  • I know it seems a very general questions, and I have searched about it. I came up with the above two solutions, with their respective problems, I have mentioned above. Other tools, are AlwaysUp which is proprietary software and there are srvany and other windows resource toolkit related tools, which are unavailable on those servers in Program Files, on which I am trying to do this. – Rohit Bagjani May 31 '17 at 05:46
  • AlwaysUp worked for me way better than other options I have mentioned above. Though it's a proprietary tool. – Rohit Bagjani Jun 02 '17 at 06:54

1 Answers1

2

The correct way to install redis as a service in windows:

redis-server --service-install --service-name "[your desired service name]" "[full path to your redis conf]"

As others have suggested the redis.conf must contain at least the minimum parameters. Try it with the default config and get more specific by including the default config in an instance specific config file per include


Another way is by using the sc create command correctly:

SC CREATE [your desired service name] binpath= "\"C:\Program Files\Redis\redis-server.exe\" --service-run \"[full path to your config]\""

Please note the whitespace after binpath=!

phil
  • 420
  • 4
  • 14