Source: stackoverflow.com --- Sunday, April 30, 2017
I'm just coding a function which has to check if some Windows services are running on remote machine. Everything would be easy if I had full access to both servers (where the application is installed, and where I want to do the check) however I don't have such access, and doing any change as opening port/adding exception in firewall can be done only by other guy and takes a long time. This is part of my code which I've written to do such check: var serverAddress = "XX.XX.XX.XX"; var servicesNames = "elasticsearch-service-x64"; var options = new ConnectionOptions(); options.Password = "myPasswordd"; options.Username = @"myDomain\myUser"; ManagementScope scope = new ManagementScope(@"\\" + serverAddress + @"\root\cimv2", options); var query = new SelectQuery("select * from Win32_Service where name = '" + servicesNames + "'"); using (var searcher = new ManagementObjectSearcher(scope, query)) { foreach (ManagementObject service in searcher.Get()) { Console.WriteLine(service.GetPropertyValue("State")); } } So, I want to list all required actions to do such operation, to be sure I won't have to ask this other guy for help more than one time. What I've found so far: Opening port, but which one? (RPC: 135, 2101*, 2103*, 2105*)? Set firewall in some specific way? User which I'm trying to add in ConnectionOptions should be administrator, and/or added into "Performance Monitor Users" group? Did I miss something? ...
from Windows http://ift.tt/2qmOv8o
No comments:
Post a Comment