Try
'#Region "Code to stop the service"
'Assign the name of the service you
want to stop on the remote machine
Dim serviceName As
String =
"Enter Remote system service name here"
'Assign the user name and password of
the account to ConnectionOptions object
'which have administrative privilege on
the remote machine.
Dim connectoptions As
New ConnectionOptions()
'connectoptions.Impersonation =
ImpersonationLevel.Impersonate;
connectoptions.Username =
"Enter Remote system login id here"
connectoptions.Password =
"Enter Remote system login password here"
'IP Address of the remote machine
Dim ipAddress As
String =
"Enter remote system ip Address here"
Dim scope As
New ManagementScope("\\"
+ ipAddress + "\root\cimv2")
scope.Options =
connectoptions
'Define the WMI query to be executed on
the remote machine
Dim query As
New SelectQuery("select
* from Win32_Service where name = '" + serviceName +
"'")
Using searcher As
New ManagementObjectSearcher(scope, query)
Dim collection As
ManagementObjectCollection = searcher.[Get]()
For Each service
As ManagementObject In
collection
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Jitendra YadavPosted May 13, 2015, 1:45 AM
At least you should mention namespace name.
crystal boyPosted Oct 25, 2012, 7:32 AM
Sorry Guys... To start the service If service("Started").Equals(False) Then 'Stop the service service.InvokeMethod("StartService", Nothing) End If