473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 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 9676
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.