473,564 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3499

"Yosh" <Yo**@nospam.co m> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
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.Diagnost ics.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******** ********@TK2MSF TNGP09.phx.gbl. ..

"Yosh" <Yo**@nospam.co m> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
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.co m> wrote in message
news:OC******** *****@TK2MSFTNG P09.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.Diagnost ics.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.Manageme nt 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.Manageme nt 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.Manageme nt;
using System.Diagnost ics;

public class Wmis {
public static void Main() {

ConnectionOptio ns co = new ConnectionOptio ns();
//get user and password
co.Username = "domain\\admini strator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authenticati on = AuthenticationL evel.PacketPriv acy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope (@"\\YourIISSer ver\root\Micros oftIISv2", co);
ServiceAction(m s, "StopServic e"); // Stop IIS
ServiceAction(m s, "StartService") ; // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format(" IIsWebService.N ame='W3SVC'");
using(Managemen tObject oW3SVC = new ManagementObjec t(ms, new
ManagementPath( mp), null))
{
ManagementBaseO bject outParams = oW3SVC.InvokeMe thod(ServiceAct ion, null,
null);
// Handle the return code, here simply display the return value
Console.WriteLi ne
((System.UInt32 )(outParams.Pro perties["ReturnValu e"].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\MicrosoftI ISv2. I get an Access Denied just trying to do a
..Get or .CreateInstance .

Any ideas?

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


"Yosh" <Yo**@nospam.co m> wrote in message
news:OC******** *****@TK2MSFTNG P09.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.Diagnost ics.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.Manageme nt 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.Manageme nt 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.Manageme nt;
using System.Diagnost ics;

public class Wmis {
public static void Main() {

ConnectionOptio ns co = new ConnectionOptio ns();
//get user and password
co.Username = "domain\\admini strator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authenticati on = AuthenticationL evel.PacketPriv acy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope (@"\\YourIISSer ver\root\Micros oftIISv2", co);
ServiceAction(m s, "StopServic e"); // Stop IIS
ServiceAction(m s, "StartService") ; // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format(" IIsWebService.N ame='W3SVC'");
using(Managemen tObject oW3SVC = new ManagementObjec t(ms, new
ManagementPath( mp), null))
{
ManagementBaseO bject outParams = oW3SVC.InvokeMe thod(ServiceAct ion, null,
null);
// Handle the return code, here simply display the return value
Console.WriteLi ne
((System.UInt32 )(outParams.Pro perties["ReturnValu e"].Value));
}
}
}
Willy.

Nov 22 '05 #5
Sounds like a permission problem. Are you the admin?
"Anton" <An***@discussi ons.microsoft.c om> wrote in message
news:10******** *************** ***********@mic rosoft.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\MicrosoftI ISv2. I get an Access Denied just trying to
do a
.Get or .CreateInstance .

Any ideas?

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


"Yosh" <Yo**@nospam.co m> wrote in message
news:OC******** *****@TK2MSFTNG P09.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.Diagnost ics.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.Manageme nt 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.Manageme nt 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.Manageme nt;
using System.Diagnost ics;

public class Wmis {
public static void Main() {

ConnectionOptio ns co = new ConnectionOptio ns();
//get user and password
co.Username = "domain\\admini strator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authenticati on = AuthenticationL evel.PacketPriv acy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope (@"\\YourIISSer ver\root\Micros oftIISv2", co);
ServiceAction(m s, "StopServic e"); // Stop IIS
ServiceAction(m s, "StartService") ; // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format(" IIsWebService.N ame='W3SVC'");
using(Managemen tObject oW3SVC = new ManagementObjec t(ms, new
ManagementPath( mp), null))
{
ManagementBaseO bject outParams = oW3SVC.InvokeMe thod(ServiceAct ion,
null,
null);
// Handle the return code, here simply display the return value
Console.WriteLi ne
((System.UInt32 )(outParams.Pro perties["ReturnValu e"].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***@discussi ons.microsoft.c om> wrote in message
news:10******** *************** ***********@mic rosoft.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\MicrosoftI ISv2. I get an Access Denied just trying to
do a
.Get or .CreateInstance .

Any ideas?

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


"Yosh" <Yo**@nospam.co m> wrote in message
news:OC******** *****@TK2MSFTNG P09.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.Diagnost ics.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.Manageme nt 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.Manageme nt 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.Manageme nt;
using System.Diagnost ics;

public class Wmis {
public static void Main() {

ConnectionOptio ns co = new ConnectionOptio ns();
//get user and password
co.Username = "domain\\admini strator"; // here domain can be the IIS
servername or a domain name
co.Password = "hispwd";
co.Authenticati on = AuthenticationL evel.PacketPriv acy; // This is the
minimum authentication level allowed

ManagementScope ms = new
ManagementScope (@"\\YourIISSer ver\root\Micros oftIISv2", co);
ServiceAction(m s, "StopServic e"); // Stop IIS
ServiceAction(m s, "StartService") ; // Start IIS
}
static void ServiceAction( ManagementScope ms, string ServiceAction)
{
string mp = String.Format(" IIsWebService.N ame='W3SVC'");
using(Managemen tObject oW3SVC = new ManagementObjec t(ms, new
ManagementPath( mp), null))
{
ManagementBaseO bject outParams = oW3SVC.InvokeMe thod(ServiceAct ion,
null,
null);
// Handle the return code, here simply display the return value
Console.WriteLi ne
((System.UInt32 )(outParams.Pro perties["ReturnValu e"].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\MicrosoftI ISv2 namespace. Luckily, an
error was generated in the EventViewer:

"Access to the root\MicrosoftI ISv2 namespace was denied. The namespace is
marked with RequiresEncrypt ion 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
RequiresEncrypt ion is configurable and is also the default. You can change
this through the WMI control (globally) or programmaticall y per connection.

In VB, it would look like this:
set locatorObj = CreateObject("W bemScripting.SW bemLocator")
locatorObj.Secu rity_.authentic ationLevel = WbemAuthenticat ionLevelPktPriv acy

In C#, it would look like this:
ConnectionOptio nsObject = new ConnectionOptio ns();
ConnectionOptio nsObject.Userna me = UserName;
ConnectionOptio nsObject.Passwo rd = Password;
ConnectionOptio nsObject.Authen tication = AuthenticationL evel.PacketPriv acy;

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***@discussi ons.microsoft.c om> wrote in message
news:10******** *************** ***********@mic rosoft.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\MicrosoftI ISv2. I get an Access Denied just trying to
do a
.Get or .CreateInstance .

Any ideas?

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

>
>
> "Yosh" <Yo**@nospam.co m> wrote in message
> news:OC******** *****@TK2MSFTNG P09.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.Diagnost ics.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.Manageme nt 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.Manageme nt 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.Manageme nt;
> using System.Diagnost ics;
>
> public class Wmis {
> public static void Main() {
>
> ConnectionOptio ns co = new ConnectionOptio ns();
> //get user and password
> co.Username = "domain\\admini strator"; // here domain can be the IIS
> servername or a domain name
> co.Password = "hispwd";
> co.Authenticati on = AuthenticationL evel.PacketPriv acy; // This is the
> minimum authentication level allowed
>
> ManagementScope ms = new
> ManagementScope (@"\\YourIISSer ver\root\Micros oftIISv2", co);
> ServiceAction(m s, "StopServic e"); // Stop IIS
> ServiceAction(m s, "StartService") ; // Start IIS
> }
> static void ServiceAction( ManagementScope ms, string ServiceAction)
> {
> string mp = String.Format(" IIsWebService.N ame='W3SVC'");
> using(Managemen tObject oW3SVC = new ManagementObjec t(ms, new
> ManagementPath( mp), null))
> {
> ManagementBaseO bject outParams = oW3SVC.InvokeMe thod(ServiceAct ion,
> null,
> null);
> // Handle the return code, here simply display the return value
> Console.WriteLi ne
> ((System.UInt32 )(outParams.Pro perties["ReturnValu e"].Value));
> }
> }
> }
>
>
> Willy.
>
>
>


Nov 22 '05 #8

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

Similar topics

0
1474
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' type command , so I can wait for the remote machine to finish, everything is synchronized in this respect.
7
717
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
6850
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 some proccess on local machine and do something. This works perfect on the machine (XP) where I have been developing this app!
2
15659
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. Maybe someone can help me out. 1) I can build the packets and put them out fine, however, I can only read incomming data if I use IOControl and...
0
1137
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 but failed to do it from asp.net the exception that i am getting is :: "Couldn't get process information from remote machine." although i am...
8
2047
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 show the cmd.exe box.) I've tried with and without UseShellExecute, and even using "cmd.exe /c myprog.exe myargs..." Launching the process from a...
0
984
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 another "To.exe" file in machine B, so the machine B now have a process called "To.exe" running. Is that possible? Thanks!!! Ronan
0
13738
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 until it's finished. If the command didn't terminate within the timeout, the command is killed. (Ex. 2) - launch the command and continue your...
1
1173
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 service.stop command. I know I can use System.diagnostics process, but its giving me error "Access denied". I wanted to use something with service...
1
4407
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 same domain as of local machine Win32::OLE(0.1701) error 0x80070005: "Access is denied" after character 0 in...
0
7665
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6255
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.