wmi

Win32_Product InstallLocation (error)

蹲街弑〆低调 提交于 2019-12-25 04:52:10
问题 in C#, i'm trying to get some properties from the instances of Win32_Product, but i seem to have an error saying "Object reference not set to an instance of an object." here's the code: class Package { public string productName; public string installDate; public string installLocation; } class InstalledPackages { public static List<Package> get() { List<Package> packages = new List<Package>(); string query = "SELECT * FROM Win32_Product"; ManagementScope oMs = new ManagementScope();

Win32_Product InstallLocation (error)

隐身守侯 提交于 2019-12-25 04:51:26
问题 in C#, i'm trying to get some properties from the instances of Win32_Product, but i seem to have an error saying "Object reference not set to an instance of an object." here's the code: class Package { public string productName; public string installDate; public string installLocation; } class InstalledPackages { public static List<Package> get() { List<Package> packages = new List<Package>(); string query = "SELECT * FROM Win32_Product"; ManagementScope oMs = new ManagementScope();

Access-Denied error upon using start-process

笑着哭i 提交于 2019-12-25 04:15:50
问题 I first want to apologize for reposting a question. I attempted to start a bounty but am having this problem and there doesn't seem to be a fix for it. Anyways I am getting the following error when trying to execute a line of code Start-Process : This command cannot be executed due to the error: Access is denied. This is the code being executed $username = "domain\username" $passwordPlainText = "password" $password = ConvertTo-SecureString "$passwordPlainText" -asplaintext -force $cred = New

How to get Processor Id from win32 processor

扶醉桌前 提交于 2019-12-25 03:38:23
问题 string strProcessorId = string.Empty; SelectQuery query = new SelectQuery("Win32_processor"); ManagementObjectSearcher search = new ManagementObjectSearcher(query); foreach (ManagementObject info in search.Get()) { strProcessorId = info["processorId"].ToString(); } Console.WriteLine(strProcessorId); Console.ReadLine(); it gives error for line strProcessorId = info["processorId"].ToString(); error is: Object reference not set to an instance of an object. how to remove this error 回答1: WMI

Querying process by CommandLine

耗尽温柔 提交于 2019-12-25 03:07:15
问题 I'm trying to do the following query in WMI: SELECT ProcessID from Win32_Process where CommandLine='C:\Windows\system32\calc.exe' But I got an "Invalid query" error. I also tried with: SELECT ProcessID from Win32_Process where CommandLine='C:\\Windows\\system32\\calc.exe' And still get the same error, also I tried to change the single quotes to double quotes but it didn't work. Does anybody know if its possible to do that query? 回答1: Yes and No. Depends on how calc.exe is spawned. For

Querying process by CommandLine

左心房为你撑大大i 提交于 2019-12-25 03:07:00
问题 I'm trying to do the following query in WMI: SELECT ProcessID from Win32_Process where CommandLine='C:\Windows\system32\calc.exe' But I got an "Invalid query" error. I also tried with: SELECT ProcessID from Win32_Process where CommandLine='C:\\Windows\\system32\\calc.exe' And still get the same error, also I tried to change the single quotes to double quotes but it didn't work. Does anybody know if its possible to do that query? 回答1: Yes and No. Depends on how calc.exe is spawned. For

Conversion of physical drive paths using C++

旧巷老猫 提交于 2019-12-25 02:27:01
问题 I'm using WMI to retrieve information about physical drives on the system: SELECT * FROM Win32_PhysicalMedia And the "Tag" property returns physical device paths such as "\.\PHYSICALDRIVE0", or "\.\CDROM0", etc. Is there a way to associate it with the actual drive paths, stuff like "C:" or "D:" or at least a device path "\Device\HarddiskVolume1"? PS. In despite of my use of WMI, I'm writing the code using WinAPIs and C++. EDIT: Below is how it's done in C++. Note that this code should not be

Python: run a process inside a windows host

て烟熏妆下的殇ゞ 提交于 2019-12-25 01:48:38
问题 I need to run a process inside a windows host from a linux host using python. I saw WMI python library but seems to work only from a windows host, not linux, how can I do? I neeed something like PSEXEC, but it works only for windows. 回答1: An easy solution is to run a SSH server on the windows box and use the paramiko library on the client side. 回答2: Since you cannot install anything on the windows host, does it have openoffice, or libreoffice installed? You coult then use the Python

kill remote process

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 21:49:30
问题 I used the below link and was able to set it up successfully: http://www.codeproject.com/Articles/26817/Killing-Processes-from-a-Visual-Basic-Application?msg=4868229#xx4868229xx I am trying to figure out how to view/kill processes for a remote workstation in VB.NET versus locally? Any ideas? I've been testing with WMI but cant seem to figure it out and get it working. Here is my class code: Public Class Form1 Public Sub endprocess(ByVal RemotePC As String, ByVal process As String) Dim

'Provider load failure' during installation process

别来无恙 提交于 2019-12-24 19:18:56
问题 I execute two Powershell scripts during a installation process from a desktop application under Windows 10 IoT Enterprise. %WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File ".\KeyboardFilter.ps1" %WINDIR%\System32\WindowsPowerShell\v1.0\PowerShell.exe -ExecutionPolicy Bypass -File ".\ShellLauncher.ps1" But the execution of the Powershell scripts is not successful. I get the following errors: Get-WMIObject : Provider load failure At C:\Program Files