473,698 Members | 2,346 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 3517

"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
1480
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
6856
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
15667
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 set the socket SIO_RCVALL. But doing this seems to apply to other sockets I maybe running in a...
0
1147
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 doing it from the same machine from where i did it successfully using vb.net. don't know the route...
8
2060
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 seperate project (not IIS) seems to work fine. Is this a permissions issue? (Though as I said, it...
0
990
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
13742
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 processing after the command has been started remotely (Ex. 3).
1
1182
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 controller. Any help will be grealty appreciated.
1
4419
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 "WinMgmts:{impersonationLevel=impersonate,(security)}!\\10.10.230.40" Error2: when my remote machine is on other domain.
0
8608
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8898
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.