Hi,
i try to create a remote process with Win32_Process.C reate, 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<stri ng, string>
ExecuteProcessR emote_TrowsExce ption(string TargetMachine, string
ProcessName, string Paramaters, string UserName, string Password)
{
try
{
ConnectionOptio ns connOptions = new ConnectionOptio ns();
connOptions.Ena blePrivileges = true;
connOptions.Imp ersonation = ImpersonationLe vel.Impersonate ;
if (UserName != string.Empty && Password != string.Empty)
{
connOptions.Use rname = UserName;
connOptions.Sec urePassword = CreateSecureStr ing(Password);
}
ManagementScope manScope = new
ManagementScope (String.Format( @"\\{0}\ROOT\CI MV2", TargetMachine),
connOptions);
manScope.Connec t();
ObjectGetOption s objectGetOption s = new ObjectGetOption s();
ManagementPath managementPath = new ManagementPath( "Win32_Process" );
ManagementClass processClass = new ManagementClass (manScope, managementPath,
objectGetOption s);
ManagementBaseO bject inParams = processClass.Ge tMethodParamete rs("Create");
inParams["CommandLin e"] = ProcessName + " " + Paramaters;
ManagementBaseO bject outParams = processClass.In vokeMethod("Cre ate",
inParams, null);
int nReturnValue = Convert.ToInt32 (outParams["returnValu e"].ToString());
switch (nReturnValue)
{
case 0:
{
return GetRemoteProces sPropertiesById (TargetMachine, UserName, Password,
nReturnValue.To String());
}
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."
i try to create a remote process with Win32_Process.C reate, 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<stri ng, string>
ExecuteProcessR emote_TrowsExce ption(string TargetMachine, string
ProcessName, string Paramaters, string UserName, string Password)
{
try
{
ConnectionOptio ns connOptions = new ConnectionOptio ns();
connOptions.Ena blePrivileges = true;
connOptions.Imp ersonation = ImpersonationLe vel.Impersonate ;
if (UserName != string.Empty && Password != string.Empty)
{
connOptions.Use rname = UserName;
connOptions.Sec urePassword = CreateSecureStr ing(Password);
}
ManagementScope manScope = new
ManagementScope (String.Format( @"\\{0}\ROOT\CI MV2", TargetMachine),
connOptions);
manScope.Connec t();
ObjectGetOption s objectGetOption s = new ObjectGetOption s();
ManagementPath managementPath = new ManagementPath( "Win32_Process" );
ManagementClass processClass = new ManagementClass (manScope, managementPath,
objectGetOption s);
ManagementBaseO bject inParams = processClass.Ge tMethodParamete rs("Create");
inParams["CommandLin e"] = ProcessName + " " + Paramaters;
ManagementBaseO bject outParams = processClass.In vokeMethod("Cre ate",
inParams, null);
int nReturnValue = Convert.ToInt32 (outParams["returnValu e"].ToString());
switch (nReturnValue)
{
case 0:
{
return GetRemoteProces sPropertiesById (TargetMachine, UserName, Password,
nReturnValue.To String());
}
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."
Comment