How to start Windows service of client system from server system? - windows

I have developed a windows service using C#.net. The purpose of this service is block an application. When ever serrvice starts the application will be blocked. Can I operate this service from server to start or stop in client system?

Try 'sc' command from the command prompt. As servers IP and services name use your own.
Starting service:
sc \\192.168.1.100 start MySQL
Stopping service:
sc \\192.168.1.100 start MySQL
More information here.

Related

Shutdown Windows When Remote Desktop Connection Closes

I am trying to build a "desktop in the cloud" using the Apache Guacamole service and Google Cloud VMs. I have accepted that I can not boot a VM on a RDP connection, but I am wondering if there is a way to shut down a machine on RDP disconnect.
I have a Windows Datacenter VM hosted as my "desktop" and Apache Guacamole hosted on another server to RDP into the desktop. To save money I would like to shut down the VM when I disconnect. Basically, when I terminate the RDP connection can I detect that and trigger shutdown?
I am not averse to writing bash or python scripts to accomplish this task, but I need some direction.
Thanks,
Owen
As per Squashman's recommendation:
I created a task in the Task Scheduler that is triggered by a disconnect from the user and had it run a bash script to shutdown the machine.
Thank you!
Script:
SHUTDOWN /p

Started SQL Server Service on cluster remotely but cluster resource is offline

I have an issue while I start SQL Server service remotely using powershell. The Service is hosted on a cluster as a cluster instance. I start the service with service name, not cluster resource name. So, I am able to bring the service online and connect to the instance, however, the cluster administrator shows the resource is offline until I bring it online. Why is this problem. Why is cluster not able to detect service status.
I don't think starting the SQL Server service will bring the SQL Cluster Resource online. Because you are only attempting to start the SQL Svcs Locally. It is as good as starting the services using service control manager.
You should rather be using Start-ClusterResource -Name <SQLClusterResourceName>

Using SC command for devices in the backend

can somebody help me with a query I have. I have a device (windows server 2008) at the backend that when it fail we need to restart a service a service in the server.
I have read that I can send a the command to the device remotly with ( sc \server stop service)
The only concern is that the device is a the backend and a some firewall rules that don't let us remote control.
SC use any port to send the command that maybe I can open in the firewall?

Service could not be started on reboot

I've programmed a small service running as Windows Service. On most computers this works well, but there are a few computers, where the service sometimes does not start when the computer is rebootet.
It is no problem to start the service after the boot. Just the automatic start right on boot does not work.
I already tried to put the service into delayed start, but this didn't Change anything. The service still sometimes not starts on reboot.
The service is running on a local service account and does just open a few WFC services and wait for connections.

run windows services in specific order

Is it possible to change the order of windows services or run one service after another?
The reason i want this: I have IIS configuration located on a shared drive. And when i reboot server, it first run IIS (w3wp) service and couldn't start it. because at that point, shared network drive is not available. So i want to first finishing the network service to map all network drives and then run IIS service. so i don't need to restart IIS service every-time i reboot the server. is there any other way to achieve this?
Thanks!
By default, some Windows services are configured with "dependencies" to ensure that the prerequisite services are started first... so you can just add to them.
Here's how to set dependencies with Registry edits , from the command-line (sc config ServiceName depend=servicetoDependOn), and from .NET.
If you're running Server 2008 / Vista / 7 you can set the IIS service for delayed start.
There are sort of two tiers: first all the "automatic" stuff, then the "automatic (delayed start)" stuff.

Resources