Windows server dependencies
I have an application which has 3 services which are dependent on SQL server.
The database used by my application is present in another machine(different from machine where i have the 3 services).
These 3 services are dependent services for SQLserver.
I have established an ODBC Connection with my DB in remote machine and my services are running fine.
Now i terminate or stop the SQLserver in the machine where my services are running. Since my services are dependent services windows will stop my services also.
Question1: Is it possible for me to remo开发者_如何学运维ve the dependency from services.msc for my services from properties of sqlserver.
Question2: Suppose i remove the dependency for my services and that i killed sqlserver exe will my services continue to work with the DB which is in a remote machine.
Thanks
Answer1: You can add/remove dependancies using the sc command
Answer2: Yes. If you remove dependancy and kill local sql server, the services will run fine with remote sql server as long as the connection string is set properly
This answer addresses the case where you have multiple dependencies on a service and only want to remove one of them. For example, you move your database to another server and want to remove the SQL Server dependency (as in the original question) but also keep the other dependencies for that service.
As noted in the other answer, sc config is the way to go, but the syntax is not obvious from that reference if you've never done it before.
The depend=
parameter takes a list of service names separated by forward slashes, i.e. /
. To remove a single dependency you just pass it a list of the current dependencies minus the one you want to remove.
To accurately determine the current dependencies, use sc qc to query the configuration information for the service. For example, for a service named vpxd:
C:\Users\me>sc qc vpxd
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: vpxd
[...]
DEPENDENCIES : ProtectedStorage
: lanmanworkstation
: MSSQL$SQLEXPRESS
We're only interested in the DEPENDENCIES
attribute, which lists three dependent services. Note that these values are the service Name
, not the more friendly DisplayName
that you see in the Windows Services snapin.
The service has to be stopped in order to modify it. So the commands to remove the SQLExpress dependency from the vpxd service would be:
# stop the service
C:\Users\me>sc stop vpxd
# configure its dependencies; the space after depend= is important.
C:\Users\me>sc config vpxd depend= ProtectedStorage/lanmanworkstation
[SC] ChangeServiceConfig SUCCESS
# start the service back up
C:\Users\me>sc start vpxd
Another way to eliminate a dependency is to uninstall its service, but that would only make sense in this example if we wanted to get rid of SQLExpress altogether.
Aside: if, like me, you tend to work from the PowerShell shell, note that sc
is a common alias for the Set-Content
cmdlet. As a consequence, all these examples were executed in the good old Cmd shell.
精彩评论