472,989 Members | 3,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Win32_Process.Create always returns 9

Hi,

i try to create a remote process with Win32_Process.Create, but the remote
machine always retruns 9 as result, which say that the path could not be
found.
Code seems to be fine, except the compiler warning (unreachable code, etc)
Here is some code:
private static Dictionary<string, string>
ExecuteProcessRemote_TrowsException(string TargetMachine, string
ProcessName, string Paramaters, string UserName, string Password)
{
try
{
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.EnablePrivileges = true;
connOptions.Impersonation = ImpersonationLevel.Impersonate;
if (UserName != string.Empty && Password != string.Empty)
{
connOptions.Username = UserName;
connOptions.SecurePassword = CreateSecureString(Password);
}
ManagementScope manScope = new
ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", TargetMachine),
connOptions);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(manScope, managementPath,
objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = ProcessName + " " + Paramaters;
ManagementBaseObject outParams = processClass.InvokeMethod("Create",
inParams, null);
int nReturnValue = Convert.ToInt32(outParams["returnValue"].ToString());
switch (nReturnValue)
{
case 0:
{
return GetRemoteProcessPropertiesById(TargetMachine, UserName, Password,
nReturnValue.ToString());
}
break;
case 2:
throw new Win32Exception(5);
break;
case 3:
throw new Win32Exception(8344);
break;
case 8:
throw new Win32Exception(13816);
break;
case 9:
throw new Win32Exception(3);
break;
case 21:
throw new Win32Exception(87);
break;
default:
break;
}
throw new Win32Exception(13816);
}
catch (Exception e)
{
throw e;
}
}

What fails here? Remote System is a Windows 2000 Computer (Professional).
I lnow that i cant spawn UI Processes (maybe at 2000 but not later) but even
a try to something like ping.exe or nslookup.exe wont work. aöway get 9 as
result.

Whats wrong here,...

Tia,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
Jun 27 '08 #1
1 9513
Hi,

ok, it was my fault. I validatet the two Parameters "ProcessName" and
"Parameters"
and they pointed to something totally wrong but a path,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"Kerem Gümrükcü" <ka*******@hotmail.comschrieb im Newsbeitrag
news:uf*************@TK2MSFTNGP04.phx.gbl...
Hi,

i try to create a remote process with Win32_Process.Create, but the remote
machine always retruns 9 as result, which say that the path could not be
found.
Code seems to be fine, except the compiler warning (unreachable code, etc)
Here is some code:
private static Dictionary<string, string>
ExecuteProcessRemote_TrowsException(string TargetMachine, string
ProcessName, string Paramaters, string UserName, string Password)
{
try
{
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.EnablePrivileges = true;
connOptions.Impersonation = ImpersonationLevel.Impersonate;
if (UserName != string.Empty && Password != string.Empty)
{
connOptions.Username = UserName;
connOptions.SecurePassword = CreateSecureString(Password);
}
ManagementScope manScope = new
ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", TargetMachine),
connOptions);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(manScope,
managementPath, objectGetOptions);
ManagementBaseObject inParams =
processClass.GetMethodParameters("Create");
inParams["CommandLine"] = ProcessName + " " + Paramaters;
ManagementBaseObject outParams = processClass.InvokeMethod("Create",
inParams, null);
int nReturnValue = Convert.ToInt32(outParams["returnValue"].ToString());
switch (nReturnValue)
{
case 0:
{
return GetRemoteProcessPropertiesById(TargetMachine, UserName, Password,
nReturnValue.ToString());
}
break;
case 2:
throw new Win32Exception(5);
break;
case 3:
throw new Win32Exception(8344);
break;
case 8:
throw new Win32Exception(13816);
break;
case 9:
throw new Win32Exception(3);
break;
case 21:
throw new Win32Exception(87);
break;
default:
break;
}
throw new Win32Exception(13816);
}
catch (Exception e)
{
throw e;
}
}

What fails here? Remote System is a Windows 2000 Computer (Professional).
I lnow that i cant spawn UI Processes (maybe at 2000 but not later) but
even
a try to something like ping.exe or nslookup.exe wont work. aöway get 9 as
result.

Whats wrong here,...

Tia,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Jun 27 '08 #2

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

Similar topics

3
by: abovetreeline | last post by:
Hi, How to make javascript terminate a win32_process? vbscript will terminate a named process with the following code: strcomputer = "." Set objwmiservice = GetObject("winmgmts:" _ &...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
3
by: Peter Neuburger via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Peter Neuburger Hi Everybody, I need some help with the WMI Terminate Method. I have a Listbox where I get all the Process...
2
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
10
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaac11/html/acfctNZ_HV05186465.asp "If the value of the variant argument is Null, the Nz function returns the number zero or a...
2
by: Jake Barnes | last post by:
Using javascript closures to create singletons to ensure the survival of a reference to an HTML block when removeChild() may remove the last reference to the block and thus destory the block is...
1
by: abcd | last post by:
I am using Python to create a process on another computer. Both computers are on the same domain with admin privileges. On computer B I have a batch script which starts a python script. From...
2
by: Joe Rattz | last post by:
I am trying to create an XmlReader using XmlReader.Create, but it always returns {None}. I have tried several examples from the web, and Create always returns "{None}". Here is my code: ...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.