Questions tagged [system.management]
103 questions
3
votes
1 answer
Using System.Drawing.Printing to get Queue Status
I've been trying to use System.Drawing.Printing; in order to get the queue status of a network printer.
I can retrieve the properties of the printer but I can't really seem to get the queue status.
This is what I've tried so far:
PrinterSettings ps…

Miquel Coll
- 759
- 15
- 49
3
votes
0 answers
C# System.Management.Automation.PowerShell Performance
Why is performance of executing a script from PowerShell directly much quicker than when executing the script from the System.Management.Automation.PowerShell class? When I execute my script directly in PS, it takes less than a second, though when I…

mservidio
- 12,817
- 9
- 58
- 84
3
votes
4 answers
Why does my .NET Windows service not start automatically sometimes?
I have modified a working Windows service that had always been starting beforehand. After adding the System.Management reference it now sometimes will not start automatically. I get the following error:
Service cannot be started.
…

Tomek
- 4,689
- 15
- 44
- 52
2
votes
1 answer
Get physical path corresponding to a network share on local computer
I want to be able to get the physical path (C:\somepath...) corresponding to an UNC path to a network share on the local computer (\\mycomputer\somepath...).
I've tried doing this using ManagementObjectSearcher as described here. This works fine…

Joe
- 122,218
- 32
- 205
- 338
2
votes
1 answer
Use ManagementObject to restart remote service
I want to restart a service on a remote machine and do not want to use ServiceController because the process to get all services on that machine took 21 seconds while the following ManagementObject returned in less than 2 seconds:
…

Jack Smit
- 3,093
- 4
- 30
- 45
2
votes
4 answers
Cannot get system identifier in WPF
I programming in WPF C# and trying to get the ProcessorID (or other system identifier). I have read through MSDN - System.Management Namespace. I add the namespace, but it does not provide ManagementBaseObject Class.
using System.Management;
/*…

KMC
- 19,548
- 58
- 164
- 253
2
votes
0 answers
Need DNS permission in windows server
I provide windows application with this code and able to add DNS zone on windows server 2019.
string site = "domain.com";
ConnectionOptions co = new ConnectionOptions();
ManagementScope _scope =new…

مهدی نبوی
- 471
- 5
- 15
2
votes
0 answers
How To Get Details of USB Device in C# .net Core Cross platform
I am working on Avalonia framework and .net core 3.0 using System.Management library to get USB device Details connected on pc. It works on windows. But when I test on mac and Linux , the application throws PlatformNotSupported Exception and says…

Suresh
- 21
- 3
2
votes
2 answers
Access Denied when using system.management for shutdown
I'm trying to create a small program in C# -MVC# 2008 Express- that will let me turn on and off the 15 computers I'm in charge of, remotely. Turning them on was easy but turning them off seems to be a bit more problematic.
First off I don’t have…

Crazyluv
- 66
- 1
- 4
2
votes
1 answer
Catch USB plug and unplug event System.InvalidCastException
I'm trying to detect USB device insertion and remove with WinForm desktop C# application:
public Form1()
{
InitializeComponent();
USB();
}
then:
private void USB()
{
WqlEventQuery weqQuery = new WqlEventQuery();
…
user10388599
2
votes
2 answers
$PSScriptRoot not set when invoking script from System.Management.Automation
I'm running a PowerShell script from a .NET application, but it's failing because $PSScriptRoot is not set. How can I set it?
Code:
var ps = PowerShell.Create();
ps.Runspace.SessionStateProxy.Path.SetLocation(dir);
var withScript =…

Swoogan
- 5,298
- 5
- 35
- 47
2
votes
1 answer
C# system.management is not loaded
I'm trying to use system.management in a C# windows forms app in VS 2017, but it just won't work.
Here is a code sample:
using System;
using System.Windows.Forms;
using System.Management;
namespace MyWMIapp
{
public partial class Form1 :…

jemandanders
- 49
- 9
2
votes
0 answers
Could not load type 'System.Management.Automation.PSSnapIn
I am remotely connected to Nano server 2016 by PowerShell. When I am trying to import a module, I get an error Could not load type 'System.Management.Automation.PSSnapIn' from assembly 'System.Management.Automation, Version=3.0.0.0.

Kartik Gupta
- 21
- 2
2
votes
0 answers
Total available graphics memory?
I know it's possible to get the Dedicated video memory using WMI (AdapterRam) but I can't seem to find anything on WMI to get both shared and total memory for my graphic card ? How it's possible to retrieve this information if wmi doesn't provide…

Da black ninja
- 359
- 1
- 6
- 19
2
votes
2 answers
select * from Win32_OperatingSystem throwing exception
I hace a WPF application and I'm am using the following to obtain the OS details of my PC:
using (ManagementObjectSearcher win32OperatingSystem = new ManagementObjectSearcher("select * from Win32_OperatingSystem"))
{
foreach (ManagementObject…

Harry Boy
- 4,159
- 17
- 71
- 122