Win32_Process.Create always returns 9

K

Kerem Gümrükcü

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

--
 
K

Kerem Gümrükcü

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ü said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top