473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Killing and Starting a Process on a Remote Machine

I am developing an application that will stop and start a process on a
remote machine. What security rights are needed for my application to be
able to do this?

Hope this makes sense.

Yosh
Nov 22 '05 #1
7 3474

"Yosh" <Yo**@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I am developing an application that will stop and start a process on a
remote machine. What security rights are needed for my application to be
able to do this?

Hope this makes sense.

Yosh


What kind of application are you starting remotely? How do you intend to
start/stop a remote application, what mechanism/API are you using in your
code?
Willy.
Nov 22 '05 #2
Willy,

The application is IIS and the file that I am wanting to Stop and Start is
inetinfo.exe. Right now, I am using the System.Diagnostics.Process class to
get a list of running processes and find the inetinfo.exe process to kill
it.

Unfortunately, I don't see a way to start a process remotely and I am
concerned about what security access rights are required to start and stop
processes on a remote machine.

Thanks,

Yosh
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in message
news:Ov****************@TK2MSFTNGP09.phx.gbl...

"Yosh" <Yo**@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
I am developing an application that will stop and start a process on a
remote machine. What security rights are needed for my application to be
able to do this?

Hope this makes sense.

Yosh


What kind of application are you starting remotely? How do you intend to
start/stop a remote application, what mechanism/API are you using in your
code?
Willy.

Nov 22 '05 #3


"Yosh" <Yo**@nospam.com> wrote in message
news:OC*************@TK2MSFTNGP09.phx.gbl...
Willy,

The application is IIS and the file that I am wanting to Stop and Start is
inetinfo.exe. Right now, I am using the System.Diagnostics.Process class
to
get a list of running processes and find the inetinfo.exe process to kill
it.

Unfortunately, I don't see a way to start a process remotely and I am
concerned about what security access rights are required to start and stop
processes on a remote machine.

Thanks,

Yosh


IIS runs as a service, so you have to issue a Start/stop command through the
Service Control Manager (SCM).

There are several ways to do this:
1. The easiest is to use the sc.exe commandline utility, but here you need
to run as a local administrator on IIS the server, or a Domain admin .
2. Using System.Management namespace classes and the WMI IISWebService class
http://msdn.microsoft.com/library/de...c9304f8ec7.asp.
Note that this requires IIS6 on the server (w2k3)
3. Using System.Management namespace classes and the WMI Win32_Service
class. Can be used for all IIS 5 and IIS6.

Here is a sample for option 2, option 3 is quite similar, consult MSDN for
details about WMI.

using System;
using System.Management;
using System.Diagnostics;

public class Wmis {
public static void Main() {

ConnectionOptions co = new ConnectionOptions();
//get user and password
co.Username = "domain\\administrator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authentication = AuthenticationLevel.PacketPrivacy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope(@"\\YourIISServer\root\MicrosoftII Sv2", co);
ServiceAction(ms, "StopService"); // Stop IIS
ServiceAction(ms, "StartService"); // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format("IIsWebService.Name='W3SVC'");
using(ManagementObject oW3SVC = new ManagementObject(ms, new
ManagementPath(mp), null))
{
ManagementBaseObject outParams = oW3SVC.InvokeMethod(ServiceAction, null,
null);
// Handle the return code, here simply display the return value
Console.WriteLine
((System.UInt32)(outParams.Properties["ReturnValue"].Value));
}
}
}
Willy.
Nov 22 '05 #4
Willy,

I don't mean to hijack this thread, but I have an issue that revolves around
this topic that I'm hoping you'll know the anser to. Basically, I can access
root\cimv2 classes from ASP.NET (and VBScript), but using the same methods, I
can't access root\MicrosoftIISv2. I get an Access Denied just trying to do a
..Get or .CreateInstance.

Any ideas?

Thanks,
Anton
"Willy Denoyette [MVP]" wrote:


"Yosh" <Yo**@nospam.com> wrote in message
news:OC*************@TK2MSFTNGP09.phx.gbl...
Willy,

The application is IIS and the file that I am wanting to Stop and Start is
inetinfo.exe. Right now, I am using the System.Diagnostics.Process class
to
get a list of running processes and find the inetinfo.exe process to kill
it.

Unfortunately, I don't see a way to start a process remotely and I am
concerned about what security access rights are required to start and stop
processes on a remote machine.

Thanks,

Yosh


IIS runs as a service, so you have to issue a Start/stop command through the
Service Control Manager (SCM).

There are several ways to do this:
1. The easiest is to use the sc.exe commandline utility, but here you need
to run as a local administrator on IIS the server, or a Domain admin .
2. Using System.Management namespace classes and the WMI IISWebService class
http://msdn.microsoft.com/library/de...c9304f8ec7.asp.
Note that this requires IIS6 on the server (w2k3)
3. Using System.Management namespace classes and the WMI Win32_Service
class. Can be used for all IIS 5 and IIS6.

Here is a sample for option 2, option 3 is quite similar, consult MSDN for
details about WMI.

using System;
using System.Management;
using System.Diagnostics;

public class Wmis {
public static void Main() {

ConnectionOptions co = new ConnectionOptions();
//get user and password
co.Username = "domain\\administrator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authentication = AuthenticationLevel.PacketPrivacy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope(@"\\YourIISServer\root\MicrosoftII Sv2", co);
ServiceAction(ms, "StopService"); // Stop IIS
ServiceAction(ms, "StartService"); // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format("IIsWebService.Name='W3SVC'");
using(ManagementObject oW3SVC = new ManagementObject(ms, new
ManagementPath(mp), null))
{
ManagementBaseObject outParams = oW3SVC.InvokeMethod(ServiceAction, null,
null);
// Handle the return code, here simply display the return value
Console.WriteLine
((System.UInt32)(outParams.Properties["ReturnValue"].Value));
}
}
}
Willy.

Nov 22 '05 #5
Sounds like a permission problem. Are you the admin?
"Anton" <An***@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Willy,

I don't mean to hijack this thread, but I have an issue that revolves
around
this topic that I'm hoping you'll know the anser to. Basically, I can
access
root\cimv2 classes from ASP.NET (and VBScript), but using the same
methods, I
can't access root\MicrosoftIISv2. I get an Access Denied just trying to
do a
.Get or .CreateInstance.

Any ideas?

Thanks,
Anton
"Willy Denoyette [MVP]" wrote:


"Yosh" <Yo**@nospam.com> wrote in message
news:OC*************@TK2MSFTNGP09.phx.gbl...
> Willy,
>
> The application is IIS and the file that I am wanting to Stop and Start
> is
> inetinfo.exe. Right now, I am using the System.Diagnostics.Process
> class
> to
> get a list of running processes and find the inetinfo.exe process to
> kill
> it.
>
> Unfortunately, I don't see a way to start a process remotely and I am
> concerned about what security access rights are required to start and
> stop
> processes on a remote machine.
>
> Thanks,
>
> Yosh


IIS runs as a service, so you have to issue a Start/stop command through
the
Service Control Manager (SCM).

There are several ways to do this:
1. The easiest is to use the sc.exe commandline utility, but here you
need
to run as a local administrator on IIS the server, or a Domain admin .
2. Using System.Management namespace classes and the WMI IISWebService
class
http://msdn.microsoft.com/library/de...c9304f8ec7.asp.
Note that this requires IIS6 on the server (w2k3)
3. Using System.Management namespace classes and the WMI Win32_Service
class. Can be used for all IIS 5 and IIS6.

Here is a sample for option 2, option 3 is quite similar, consult MSDN
for
details about WMI.

using System;
using System.Management;
using System.Diagnostics;

public class Wmis {
public static void Main() {

ConnectionOptions co = new ConnectionOptions();
//get user and password
co.Username = "domain\\administrator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authentication = AuthenticationLevel.PacketPrivacy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope(@"\\YourIISServer\root\MicrosoftII Sv2", co);
ServiceAction(ms, "StopService"); // Stop IIS
ServiceAction(ms, "StartService"); // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format("IIsWebService.Name='W3SVC'");
using(ManagementObject oW3SVC = new ManagementObject(ms, new
ManagementPath(mp), null))
{
ManagementBaseObject outParams = oW3SVC.InvokeMethod(ServiceAction,
null,
null);
// Handle the return code, here simply display the return value
Console.WriteLine
((System.UInt32)(outParams.Properties["ReturnValue"].Value));
}
}
}
Willy.

Nov 22 '05 #6
Yes. I concur, I do believe it to be a security issue. I'm using a domain
admin account that is also in the local Administrator group on both machines.
I have no troubles accessing it locally, but remotely, I cannot access the
IIS WMI classes. From the same ASP.NET application, I can create directories
and access root\cimv2 classes remotely.

The environment is a W2K3 domain, with both servers running W2K3, SP1.

"Yosh" wrote:
Sounds like a permission problem. Are you the admin?
"Anton" <An***@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Willy,

I don't mean to hijack this thread, but I have an issue that revolves
around
this topic that I'm hoping you'll know the anser to. Basically, I can
access
root\cimv2 classes from ASP.NET (and VBScript), but using the same
methods, I
can't access root\MicrosoftIISv2. I get an Access Denied just trying to
do a
.Get or .CreateInstance.

Any ideas?

Thanks,
Anton
"Willy Denoyette [MVP]" wrote:


"Yosh" <Yo**@nospam.com> wrote in message
news:OC*************@TK2MSFTNGP09.phx.gbl...
> Willy,
>
> The application is IIS and the file that I am wanting to Stop and Start
> is
> inetinfo.exe. Right now, I am using the System.Diagnostics.Process
> class
> to
> get a list of running processes and find the inetinfo.exe process to
> kill
> it.
>
> Unfortunately, I don't see a way to start a process remotely and I am
> concerned about what security access rights are required to start and
> stop
> processes on a remote machine.
>
> Thanks,
>
> Yosh

IIS runs as a service, so you have to issue a Start/stop command through
the
Service Control Manager (SCM).

There are several ways to do this:
1. The easiest is to use the sc.exe commandline utility, but here you
need
to run as a local administrator on IIS the server, or a Domain admin .
2. Using System.Management namespace classes and the WMI IISWebService
class
http://msdn.microsoft.com/library/de...c9304f8ec7.asp.
Note that this requires IIS6 on the server (w2k3)
3. Using System.Management namespace classes and the WMI Win32_Service
class. Can be used for all IIS 5 and IIS6.

Here is a sample for option 2, option 3 is quite similar, consult MSDN
for
details about WMI.

using System;
using System.Management;
using System.Diagnostics;

public class Wmis {
public static void Main() {

ConnectionOptions co = new ConnectionOptions();
//get user and password
co.Username = "domain\\administrator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authentication = AuthenticationLevel.PacketPrivacy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope(@"\\YourIISServer\root\MicrosoftII Sv2", co);
ServiceAction(ms, "StopService"); // Stop IIS
ServiceAction(ms, "StartService"); // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format("IIsWebService.Name='W3SVC'");
using(ManagementObject oW3SVC = new ManagementObject(ms, new
ManagementPath(mp), null))
{
ManagementBaseObject outParams = oW3SVC.InvokeMethod(ServiceAction,
null,
null);
// Handle the return code, here simply display the return value
Console.WriteLine
((System.UInt32)(outParams.Properties["ReturnValue"].Value));
}
}
}
Willy.


Nov 22 '05 #7
I finally tracked it down. Turns out that each namespace in the CIM
repository has a security descriptor to control access. I was able to
access root\cimv2 just fine from ASP.NET and VBScript, but was getting Access
Denied when trying to access the root\MicrosoftIISv2 namespace. Luckily, an
error was generated in the EventViewer:

"Access to the root\MicrosoftIISv2 namespace was denied. The namespace is
marked with RequiresEncryption but the client connection was attempted with
an authentication level below Pkt_Privacy. Re try the connection using
Pkt_Privacy authentication level."

Before Windows Server 2003 SP1, providers could not set namespace security
to require encryption before returning data. It looks like with SP1, the
RequiresEncryption is configurable and is also the default. You can change
this through the WMI control (globally) or programmatically per connection.

In VB, it would look like this:
set locatorObj = CreateObject("WbemScripting.SWbemLocator")
locatorObj.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy

In C#, it would look like this:
ConnectionOptionsObject = new ConnectionOptions();
ConnectionOptionsObject.Username = UserName;
ConnectionOptionsObject.Password = Password;
ConnectionOptionsObject.Authentication = AuthenticationLevel.PacketPrivacy;

I have not tested this on other platforms outside of W2K3, SP1, as it
presumably wasn't needed.

"Anton" wrote:
Yes. I concur, I do believe it to be a security issue. I'm using a domain
admin account that is also in the local Administrator group on both machines.
I have no troubles accessing it locally, but remotely, I cannot access the
IIS WMI classes. From the same ASP.NET application, I can create directories
and access root\cimv2 classes remotely.

The environment is a W2K3 domain, with both servers running W2K3, SP1.

"Yosh" wrote:
Sounds like a permission problem. Are you the admin?
"Anton" <An***@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
Willy,

I don't mean to hijack this thread, but I have an issue that revolves
around
this topic that I'm hoping you'll know the anser to. Basically, I can
access
root\cimv2 classes from ASP.NET (and VBScript), but using the same
methods, I
can't access root\MicrosoftIISv2. I get an Access Denied just trying to
do a
.Get or .CreateInstance.

Any ideas?

Thanks,
Anton
"Willy Denoyette [MVP]" wrote:

>
>
> "Yosh" <Yo**@nospam.com> wrote in message
> news:OC*************@TK2MSFTNGP09.phx.gbl...
> > Willy,
> >
> > The application is IIS and the file that I am wanting to Stop and Start
> > is
> > inetinfo.exe. Right now, I am using the System.Diagnostics.Process
> > class
> > to
> > get a list of running processes and find the inetinfo.exe process to
> > kill
> > it.
> >
> > Unfortunately, I don't see a way to start a process remotely and I am
> > concerned about what security access rights are required to start and
> > stop
> > processes on a remote machine.
> >
> > Thanks,
> >
> > Yosh
>
>
>
> IIS runs as a service, so you have to issue a Start/stop command through
> the
> Service Control Manager (SCM).
>
> There are several ways to do this:
> 1. The easiest is to use the sc.exe commandline utility, but here you
> need
> to run as a local administrator on IIS the server, or a Domain admin .
> 2. Using System.Management namespace classes and the WMI IISWebService
> class
> http://msdn.microsoft.com/library/de...c9304f8ec7.asp.
> Note that this requires IIS6 on the server (w2k3)
> 3. Using System.Management namespace classes and the WMI Win32_Service
> class. Can be used for all IIS 5 and IIS6.
>
> Here is a sample for option 2, option 3 is quite similar, consult MSDN
> for
> details about WMI.
>
> using System;
> using System.Management;
> using System.Diagnostics;
>
> public class Wmis {
> public static void Main() {
>
> ConnectionOptions co = new ConnectionOptions();
> //get user and password
> co.Username = "domain\\administrator"; // here domain can be the IIS
> servername or a domain name
> co.Password = "hispwd";
> co.Authentication = AuthenticationLevel.PacketPrivacy; // This is the
> minimum authentication level allowed
>
> ManagementScope ms = new
> ManagementScope(@"\\YourIISServer\root\MicrosoftII Sv2", co);
> ServiceAction(ms, "StopService"); // Stop IIS
> ServiceAction(ms, "StartService"); // Start IIS
> }
> static void ServiceAction( ManagementScope ms, string ServiceAction)
> {
> string mp = String.Format("IIsWebService.Name='W3SVC'");
> using(ManagementObject oW3SVC = new ManagementObject(ms, new
> ManagementPath(mp), null))
> {
> ManagementBaseObject outParams = oW3SVC.InvokeMethod(ServiceAction,
> null,
> null);
> // Handle the return code, here simply display the return value
> Console.WriteLine
> ((System.UInt32)(outParams.Properties["ReturnValue"].Value));
> }
> }
> }
>
>
> Willy.
>
>
>


Nov 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: student | last post by:
Hi, I am working on a project where I need to start processes on remote machines, across mac, linux, windows from one server or 'manager' machine. For now, I only need to implement a 'wait'...
7
by: Yosh | last post by:
I am developing an application that will stop and start a process on a remote machine. What security rights are needed for my application to be able to do this? Hope this makes sense. Yosh
7
by: Denis Brkljacic | last post by:
Hi, I have made some simple ASP.NET (C#) application, that somewhere uses this command: Process aProcesses = Process.GetProcesses(Environment.MachineName); This command purpose is to find...
2
by: banduraj | last post by:
I am working on starting and managing TCP connections manually. I build the IP headers and TCP packets manually and send them on my own. The problems I run into seems to be related to the Sockets....
0
by: Shruti A via .NET 247 | last post by:
hello group I have recently started working on .Net platform. I am facing one problem in killing and starting process from my aspx page. I am able to kill and start the same process from vb.net...
8
by: Mike | last post by:
Inside a HttpHandler I'm trying to spawn an EXE (console app). Although it shows up in the process list, it doesn't seem to do anything. (And even if I specify ProcessWindowStyle.Normal, it doesn't...
0
by: Ronan | last post by:
Does anybody knows how can I execute a process from one machine in another one? For example: I´m executing a "From.exe" file in a machine A, and the code of "From.exe" in that machine execute...
0
by: Patrick A. | last post by:
Dll written in VB.NET 2003 to start a command remotely. You can : - launch the command and wait until it's finished. (Ex. 1) - launch the command providing a timeout in seconds, it will wait...
1
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I am using service controller class to start, stop services on my remote machine. Is there any way I can also do the kill command for the services that hung up when I issue the...
1
shrek123
by: shrek123 | last post by:
I want to kill some process on remote machine which is on some other domain. I am using Win32::OLE GetObject to do that. But I am getting following error Error1: When my remote machine is on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.