xinglp Posted April 3, 2011 Share Posted April 3, 2011 (edited) Can I set environment value for a service before it start, without affect others . Edited April 3, 2011 by xinglp Link to comment Share on other sites More sharing options...
allen2 Posted April 3, 2011 Share Posted April 3, 2011 Yes but it might be slightly complex and your service might not accept it. There are 3 ways to do it :- The first two is create a new service with instsrv et srvany from the resource kit :- make the new service launch a cmd which will set the variable and launch directly the executable launched by the original service- or make a new service launch a cmd which will modify in the registry the environment variable and then launch the service sleep a little and remove the added reg entry -The third way is to use a specific user for this service and set the variable for this specific user only. This is the easiest way if your service support it. Link to comment Share on other sites More sharing options...
xinglp Posted April 4, 2011 Author Share Posted April 4, 2011 > The first two is create a new service with instsrv et srvany from the resource kit :> make the new service launch a cmd which will set the variable and launch directly the executable launched by the original serviceI just put the service's exe path to "svc.cmd" , and create a service bysc create XXX binPath= path\to\svc.cmdbut when I start it , met the error below1053The service did not respond to the start or control request in a timely fashion. Link to comment Share on other sites More sharing options...
allen2 Posted April 4, 2011 Share Posted April 4, 2011 You need srvany.exe et instsrv from the resource kit. Link to comment Share on other sites More sharing options...
xinglp Posted April 5, 2011 Author Share Posted April 5, 2011 You need srvany.exe et instsrv from the resource kit.It has nonthing to do with the srvany, instsrv or sc. The service cmd need " @echo off " Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now