473,387 Members | 1,416 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,387 software developers and data experts.

System.Management.ManagementException: Invalid parameter

Ravi L
12
I have created a windows Service which invokes executables on remote machines, waits for it to complete and then proceeds to the next machine on the network.
The Account type for the windows Service is "Network Service". For monitoring if the process is completed on the remote machine, I am using ManagementEventWatcher class. I get the following error when I start the Management event watcher object.

System.Management.ManagementException: Invalid parameter
at System.Management.ManagementException.ThrowWithExt endedInfo(ManagementStatus errorCode)
at System.Management.ManagementEventWatcher.Start()

The code I am using is as follows:

Dim connection As New System.Management.ConnectionOptions
connection.Username = v_sUserName
connection.Password = v_sPassword
connection.EnablePrivileges = True

Dim oPath As New ManagementPath("\\" & v_sServerName & "\root\CIMV2")
Dim oScope As New System.Management.ManagementScope(oPath, connection)
oScope.Options.Impersonation = ImpersonationLevel.Impersonate
oScope.Connect()

Dim processClass = New System.Management.ManagementClass("Win32_Process")
processClass.Scope = oScope

Dim inParams = processClass.GetMethodParameters("Create")
inParams("CommandLine")="C:\Myfolder\myexe.exe"
Dim oOutParams As ManagementBaseObject = processClass.InvokeMethod("Create", inParams, Nothing)
Dim sWQLQry As String = "SELECT * FROM __InstanceOperationEvent " & _ "WITHIN 2 WHERE TargetInstance ISA 'Win32_Process' " & _
"AND TargetInstance.Name = '" & "MPSFileAuditSatellite.exe" & "'"

Dim oWatcher As ManagementEventWatcher = New ManagementEventWatcher(oScope, oWQL)
oWatcher.Start()'I presume the error is here.
'Logic to wait for the process to exit.

what is wrong in the scope?
It used to work earlier when the service was of type User. Does this depend on the service account type and does not work when using Network Service?

Thanks in advance.
Oct 21 '10 #1
1 6708
Ravi L
12
I have an update on this. The exception occurs only when the Service account is of type NetWork Service. If it is a User type it works smooth.
Oct 21 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ger | last post by:
Hi, I have a problem with a Windows Service that I have created accessing System.Management.dll on a W2k3 environment. The Service runs fine on an XP machine but the same Service causes an error...
0
by: Martin | last post by:
I have Panel embedded in a Form. The panel has a PaintEventHandler to catch PaintEvents. When a PaintEvent occurs a new Thread which moves a Ellipse should be created. The Code: private void...
0
by: Masood Siddiqi [MSFT] | last post by:
Hi, I am getting this exception Unhandled Exception: System.Management.ManagementException: COM object that has been separated from its underlying RCW can not be used. --->...
2
by: Rubycon | last post by:
Hi all, can anybody tell me what he invalid parameter is in this code. When I try to execute the mmioDescendParent I get a returncode 11, meaning that an invalid parameter has been passed. I...
0
by: Eric Carr | last post by:
Hi, we have been using WMI from VB6 to automate configuration of new DNS zones on our win2000 servers, and are now trying to move the system to a vb.net application. We recently added some...
1
by: theintrepidfox | last post by:
Dear Group I wonder whether anyone has some information on the cause for this error? I've created a class for Win32_BIOS with mgmtclassgen Win32_BIOS /L VB, added the file to my VB.NET project...
1
by: lcifers | last post by:
I have an application that uses the following code to return the default printer: Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim...
2
by: Lamis | last post by:
Hi, I need urgent help, this is my code to rename my hostName: (MY computer is not member of domain) string compName = System.Windows.Forms.SystemInformation.ComputerName.ToString();...
0
by: =?Utf-8?B?YXBvY283Ng==?= | last post by:
Hello, I'm using WMI to query the Event Logs for a particular computer. This Event Log has over 400,000 entries. The application runs without errors until record 260,000 then it throws this...
2
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.