Click here to Skip to main content
15,914,162 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

Can anybody tell me how to check the service StartUp type which is in Another System using C# with ASP.Net


Regards,
Prabhu P
Posted
Updated 23-May-12 11:11am
v3

Have you tried this method here[^]?

Regards,

Manfred
 
Share this answer
 
Comments
fjdiewornncalwe 22-May-12 13:30pm    
OP's answer moved to comment:
Hi Manfred,

Thanks for your reply . I want check the service start up type for the many servers by passing the server names .

Regards,
Prabhu
Zoltán Zörgő 22-May-12 13:54pm    
This is really a task for PowerShell. http://powershell.com/cs/media/p/1945.aspx
Prabhu_Pappu 23-May-12 4:46am    
is this same is not possible in the C# ?
If possible please anybody guide me..

thanks in advance
You can use ServiceController[^] class to access services even on remote server.
This is also a good starting point: http://www.geekpedia.com/tutorial225_Listing-Services-with-Csharp.html[^].
 
Share this answer
 
v2
Comments
Prabhu_Pappu 23-May-12 14:21pm    
Hi All,

Let me clarify one thing ,
I want to check the Startup Type of the services for another servers.
Same server means we can use the above link "http://www.geekpedia.com/tutorial225_Listing-Services-with-Csharp.html".
But i want to check the start up type of the service which is in another system
Zoltán Zörgő 23-May-12 16:08pm    
Have you read the MSDN page about ServiceController? I assume not. If you would, you have been seen the constructor with two parameters: http://msdn.microsoft.com/en-us/library/ssbk2tf3.aspx. The second one is machineName. What's wrong with that?
If you would have looked carefully on the geekpedia link, you have been checked the ManagementClass, and seen, that it can be constructed with remote server scope.
So, both approaches are suitable for your purposes... you just need a little coding...
Prabhu_Pappu 23-May-12 17:07pm    
Thanks for your Reply :) .

In Service Controller(http://msdn.microsoft.com/en-us/library/ssbk2tf3.aspx),

we can check the ServiceName , Status, MachineName , DisplayName etc.
But, We cannot check the Service Startup Type. Ex : Auto , Disabled etc.
Zoltán Zörgő 23-May-12 17:17pm    
Well, that's true. You need to extend it: http://www.codeproject.com/Articles/7665/Extend-ServiceController-class-to-change-the-Start
Or, simply use the other, WMI based approach. See StartMode property: http://msdn.microsoft.com/en-us/library/windows/desktop/aa394418(v=vs.85).aspx
Prabhu_Pappu 23-May-12 17:28pm    
Hi again,
Even the above link (http://www.codeproject.com/Articles/7665/Extend-ServiceController-class-to-change-the-Start) we cannot pass the server Name.
Even this too ,
http://msdn.microsoft.com/en-us/library/windows/desktop/aa394418%28v=vs.85%29.aspx.

If we want to check the local system service start type we can use the above coding :) . But not for other system. :(
Can use PowerShell if you have the remote app installed. Can easily interface Powershell to C#. See How to run PowerShell scripts from C#[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900