Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am trying to figure out how to restart certain services on remote machines. The screen has a place to input the ip address or machine name of the remote computer and then there is a combobox that has a list of the certain services. What I am trying to figure out is in the code to have the computer name or ip address that is typed in to go in where I have textbox1.text but doesn't seem to work with the "" around it.

What I have tried:

Here is the code I have:

VB
Process.Start("CMD", "/C sc \\Textbox1.text start Spooler")


I have also tried:

VB
Shell("sc \\Textbox1.text start Spooler")


Is there something else I am missing or am I looking at this all wrong? Any help is greatly appreciated. Thank you
Posted
Updated 24-Mar-16 6:39am

Please do basic research before asking a question such as using google. Use the ServiceController class

ServiceController Class (System.ServiceProcess)[^]

ServiceController Constructor (String, String) (System.ServiceProcess)[^]

Obviously the account your code is running under will need the required permissions.
 
Share this answer
 
Quote:
Is there something else I am missing


Yes. A very basic understanding of how strings work.
"/C sc \\Textbox1.text start Spooler"

This assumes you have a server on your network with the actual name of "Textbox1.text". I seriously doubt that.

This tells me that you don't have the smallest clue how strings work and how to get the value of a textbox into a string. You really need to start with the basics. I seriousy recommend you pick up a beginners book on VB.NET and start working through it.

This line really should be something along the line of
Dim args = String.Format("/C sc \\{0} start Spooler", Textbox1.Text)


But, there's a ton more wrong with what you're doing. I don't have the time to dig into that right now and a forum environment isn't the place for this.
 
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