By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,855 Members | 1,970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,855 IT Pros & Developers. It's quick & easy.

Win32_Process.Create always returns 9

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.