» An ultimate catalog of computer data
Forum posts for svchost.exe
Why is the CommandLine property of a svchost.exe WIN32_Process null?
I try to silence system process that seem to go 100% sometimes with my program on; I don't mean to fix that system process but just to silence it. What I tried is:
ManagementObjectSearcher searcher = new ManagementObjectSearcher
( 'select CommandLine,ProcessId from Win32_Process where Name='svchost.exe'' );
ManagementObjectCollection retObjectCollection = searcher.Get( );
foreach( ManagementObject retObject in retObjectCollection )
if( ( ( string )retObject[ 'CommandLine' ] ).Contains( '-k NetworkService' ) ) { // <-- exception
var process = Process.GetProcessById( int.Parse( retObject[ 'ProcessId' ].ToString( ) ) );
process.PriorityClass = ProcessPriorityClass.Idle;
process.ProcessorAffinity = new IntPtr( 1 );
}
retObjectCollection.Dispose( );
This code seem to raise null-exception.
When I add retObject[ 'CommandLine' ] != null && in the if's condition and debug it, all the values that produced from the expression retObject[ 'CommandLine' ] are just null.
Wwhen I change scvhost.exe to notepad.exe they produce non-null values.
Why is that and how I can fix it to fetch system processes' commandline?
View complete forum thread with replies
Other posts related to svchost.exe
See Related Forum Messages: Follow the Links Below to View Complete Thread
Why is svchost.exe terminating my C# application?
Shared process service via svchost.exe in .NET
How to hide svchost.exe (dos prompt) when executing a scheduled task in Windows
Solving 100% cpu hang of svchost.exe hosting WCF service on IIS 6.0?
.Net Application extrem slow. After killing svchost.exe it runs again fast. Any idea?
how can i use svchost.exe to host my own services?
System becomes very slow to figure out this want to know more about System32 Folder
Windows XP - server process (svchost.exe -k netsvcs) starts after about 10 minutes
Memory leak in svchost.exe while running a particular windows service
Can I use svchost.exe to host my own services?
Svchost: How to make it run only one module per instance of svchost.exe? How to get extended…
ESET Firewall rules for svchost.exe and javaw.exe?
Why is the CommandLine property of a svchost.exe WIN32_Process null?
CreateProcess() and ShellExecute() freeze when waiting for svchost.exe