Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Starting/Stopping a service on another machine remotely from VB.NET

Posted on 2006-06-29
2
Medium Priority
?
867 Views
Last Modified: 2012-05-05
Can I start and stop services to another machine via VB or VB.NET code?  I have seen some code that allows me to start and stop a service on the same machine.  I did not see any parameter for machine name. If possible any sample code would be appreciated...Thanks

0
Comment
Question by:andyringle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 41

Accepted Solution

by:
graye earned 2000 total points
ID: 17017662
It's actually pretty straight forward...

' add a reference to System.ServiceProcess.dll
Imports System.ServiceProcess

        Dim sc As ServiceController
        sc = New ServiceController("TermService", PC)
        sc.Start()
        sc.WaitForStatus(ServiceControllerStatus.Running)

and

        sc = New ServiceController("TermService", PC)
        sc.Stop()
        sc.WaitForStatus(ServiceControllerStatus.Stopped)
0
 

Author Comment

by:andyringle
ID: 17018378
Thanks, that worked perfectly!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question