- Home /
Check If Service Is Running C#?
Hello,
I'm trying to check if a specific service is running on Windows, but so far haven't been able to get the framework correctly imported. I know I need to import some .NET framework, but when I put in the one that I need, Unity seems now to support it.
Any ideas?
Thanks.
Answer by $$anonymous$$ · Feb 18, 2019 at 11:24 PM
You can do it with cmd in c#
public void CMD(string command){
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.Arguments = "/user:Administrator \"cmd /K " + command + "\""
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "command";
process.StartInfo = startInfo;
process.Start();
}
CMD(QueryHere);
i havent tested the code but if it has any errors just tell me
Hi, is line 5 supposed to have a semi-colon to finish it?
Also, what's going on with the C$$anonymous$$D at the bottom, I've put a string value in and it's telling me to declare a body.
Thanks.
I think i fixed all the errors again havent tested the code
public void C$$anonymous$$D(string command){
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.Arguments = "/user:Ad$$anonymous$$istrator \"cmd /$$anonymous$$ " + command + "\"";
startInfo.FileName = "cmd.exe";
startInfo.Arguments = command;
process.StartInfo = startInfo;
process.Start();
}
C$$anonymous$$D("QueryHere");
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to make GUI Labels and Buttons show in a GUI Window 1 Answer
Overlapping Unity Players w/ Transparency 1 Answer
Open With... a Build Unity program 3 Answers