Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.NET WMI remote process create

40 views
Skip to first unread message

Jeremy

unread,
Sep 11, 2002, 11:41:04 AM9/11/02
to
I have c# code that will start a process on my machine,
but when I try to run it remotely, if fails. What I
would like to do is start a process on a remote machine
using .NET but so far haven't been able to.

Here is the code that I am using ->

ConnectionOptions options = new ConnectionOptions();
options.EnablePrivileges = true;
options.Authentication =
System.Management.AuthenticationLevel.Call;
options.Impersonation = ImpersonationLevel.Impersonate;
string strConnectTo = "\\\\" + m_strRemote
+ "\\root\\cimv2";
ManagementScope scope = new ManagementScope(strConnectTo);
scope.Connect();
ManagementClass processClass = new ManagementClass
("Win32_Process");
processClass.Scope = scope;

ManagementBaseObject inParams =
processClass.GetMethodParameters("Create");

inParams["CommandLine"] = "calc.exe";

ManagementBaseObject outParams =
processClass.InvokeMethod ("Create", inParams, null);


[MS] Chung-Wei Foong

unread,
Sep 11, 2002, 2:40:06 PM9/11/02
to
You may try giving this user remote enable access to the namespace.
Depending on which OS you are going to, you can use WMI control application
to configure it on the remote machine.

The following is a link to setting user security.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
setting_user_security.asp

Regards,
Chung Wei

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jeremy" <j_kerchev...@msn.com> wrote in message
news:fc7701c259a9$a38bfa00$35ef2ecf@TKMSFTNGXA11...

[MS] Chung-Wei Foong

unread,
Sep 11, 2002, 2:38:45 PM9/11/02
to
You may try giving this user remote enable access to the namespace.
Depending on which OS you are going to, you can use WMI control application
to configure it on the remote machine.

The following is a link to setting user security.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
setting_user_security.asp

Regards,
Chung Wei

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jeremy" <j_kerchev...@msn.com> wrote in message
news:fc7701c259a9$a38bfa00$35ef2ecf@TKMSFTNGXA11...

Jeremy

unread,
Sep 16, 2002, 7:34:34 PM9/16/02
to
Unfortunately I don't fully understand what you want me
to try here. What WMI Control application are we talking
about?

Jeremy

>.
>

[MS] Scott McNairy

unread,
Sep 17, 2002, 4:05:08 PM9/17/02
to
Right click "My Computer"
then select "Manage"
expand "Services and Applications"
select "WMI Control" and then right click it and select "Properties"
select "Security" Tab
give the user the permissions to the namespace mentioned below...

--
[MS] Scott McNairy
WMI Test Engineer


This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Jeremy" <jkerchev...@expressmetrix.com> wrote in message
news:0dfc01c25dd9$9ceb7c00$9de62ecf@tkmsftngxs01...

Jeremy

unread,
Sep 18, 2002, 7:47:55 PM9/18/02
to
Thanks for the reply. So, it still doesn't work
from .NET, and I have an additional question now.
Would you need to set these permission at each computer
that a Domain Admin would want to remotely start a
process? That wouldn't seem right.

Jeremy

>.
>

[MS] Scott McNairy

unread,
Sep 18, 2002, 9:11:59 PM9/18/02
to
No, domain admins are granted remote access to these namespaces on the
domain computers by default.

As far as the other issue goes, are you sure that it didn't create the
process because when executed against Windows XP or Win2k SP3 the process
will not be created interactively, it will be hidden but you can still see
the process in Task Manager. Please verify this before I look at your code.

--
[MS] Scott McNairy
WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Jeremy" <jkerc...@expressmetrix.com> wrote in message
news:28fe01c25f6d$cf1fffd0$35ef2ecf@TKMSFTNGXA11...

Jeremy

unread,
Sep 19, 2002, 7:11:07 PM9/19/02
to
Ok, I have DomainAdmin priveleges on my computer (where I
initiate the call from). I am trying to do this via .NET
(code is below already), but I have some sample script
from MS's site
<http://www.microsoft.com/technet/treeview/default.asp?
url=/technet/scriptcenter/compmgmt/ScrCM28.asp> that
shows how to do this via scripting - and that doesn't
seem to work either. The error I get from the script
is "A security package specific error occurred." Code:
80070721.

When I run the .NET code below I get is "An unhandled
exception of type 'System.ExecutionEngineException'
occurred in system.management.dll"

So, I can't get it to work in any environment.

Thanks,
Jeremy

>.
>

Ivan Brugiolo [MS]

unread,
Sep 19, 2002, 8:56:11 PM9/19/02
to
looks the error that you get back when Kerberos is used,
but no Principal is specified.

Can you repro this via Wbemtest.exe ?

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Jeremy" <jkerc...@expressmetrix.com> wrote in message

news:389a01c26031$d5a17ef0$39ef2ecf@TKMSFTNGXA08...

Jeremy

unread,
Sep 23, 2002, 2:50:32 PM9/23/02
to
Ok,
the following code
****
//Build an options object for the connection

ConnectionOptions options = new ConnectionOptions();
options.EnablePrivileges = true;
options.Impersonation = ImpersonationLevel.Impersonate;

//Make a connection to a remote computer using these
options
string strConnectTo = "\\\\" + m_srCurrent
+ "\\root\\cimv2";
try
{


ManagementScope scope = new ManagementScope(strConnectTo);
scope.Connect();

if (!scope.IsConnected)
{
MessageBox.Show("Not Connected to " + m_srCurrent);
return;
}
//Get the object on which the method will be invoked


ManagementClass processClass = new ManagementClass
("Win32_Process");
processClass.Scope = scope;

// Option 1: Invocation using parameter objects
//================================================
//Get an input parameters object for this method
ManagementBaseObject inParams = null;
// The following call gives a


inParams = processClass.GetMethodParameters("Create");

//Fill in input parameter values
inParams["CommandLine"] = "notepad.exe";
//Execute the method


ManagementBaseObject outParams =
processClass.InvokeMethod ("Create", inParams, null);
}

catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
*****

Works against a .NET Server (RC1), and it is running non-
interactively. However, running the same exact code
against a Win2k (no SPs) results in


"An unhandled exception of
type 'System.ExecutionEngineException' occurred in

system.management.dll" on the

inParams = processClass.GetMethodParameters("Create");

line.

>.
>

Jeremy

unread,
Sep 23, 2002, 7:36:52 PM9/23/02
to
I can create a new process using the wbemtest from XP to
Win2K, but cannot do it from Win2k to XP?

Also,
I can use the .NET code from Windows XP to .NET Server,
but it fails from Windows XP to Windows 2000.

Jeremy

>.
>

Ivan Brugiolo [MS]

unread,
Sep 23, 2002, 7:41:41 PM9/23/02
to
Assuming you have the most recent SP on W2K,
where exactly do you fail in the execution of the Win32_Process.Create
method from Win2K to WinXP ?

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Jeremy" <jkerc...@expressmetrix.com> wrote in message

news:5ee301c2635a$1867d6a0$2ae2...@phx.gbl...

Duke Sun

unread,
Oct 9, 2002, 3:55:49 AM10/9/02
to
Could you provide the reproduction steps in more details, so that I can
perform more research on the issue and give a resolution?

Ori

unread,
Dec 8, 2002, 5:14:11 PM12/8/02
to
Is there a way to make it run interactively on win2k sp3 and later?
(Using win32_process.create() or some other way)
Ori

"[MS] Scott McNairy" <sco...@online.microsoft.com> wrote in message
news:3d89245e$1...@news.microsoft.com...

Ivan Brugiolo [MS]

unread,
Dec 8, 2002, 2:00:32 PM12/8/02
to
Unless there's a bug in the code,
I hope there are no ways through WinMgmt to run a process
in the interactive windowstation\desktop.

--
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Ori" <ori....@appilog.com> wrote in message
news:u7at1LrnCHA.456@TK2MSFTNGP11...

0 new messages