Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

Can I set environment value for a service ?

- - - - -

  • Please log in to reply
4 replies to this topic

#1
xinglp

xinglp

    Newbie

  • Member
  • 13 posts
  • Joined 04-September 09
Can I set environment value for a service before it start, without affect others .

Edited by xinglp, 03 April 2011 - 11:20 AM.

smartutils.sf.net


How to remove advertisement from MSFN

#2
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
  • Joined 13-January 06
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.

#3
xinglp

xinglp

    Newbie

  • Member
  • 13 posts
  • Joined 04-September 09
> 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

I just put the service's exe path to "svc.cmd" , and create a service by

sc create XXX binPath= path\to\svc.cmd

but when I start it , met the error below

1053
The service did not respond to the start or control request in a timely fashion.
smartutils.sf.net

#4
allen2

allen2

    Not really Newbie

  • Member
  • PipPipPipPipPipPipPip
  • 1,812 posts
  • Joined 13-January 06
You need srvany.exe et instsrv from the resource kit.

#5
xinglp

xinglp

    Newbie

  • Member
  • 13 posts
  • Joined 04-September 09

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 "
smartutils.sf.net




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users