wmi

How to get Process Owner by Python using WMI?

空扰寡人 提交于 2019-12-23 05:50:49
问题 I tried to get some information about Process Owner, using WMI. I tried to run this script: import win32com.client process_wmi = set() strComputer = "." objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator") objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2") process_list = objSWbemServices.ExecQuery("Select * from Win32_Process") for process in process: owner = process.GetOwner if owner != 0: print('Access denied') else: print('process: ',process.Name,

Use C# BCD WMI Provider to SafeBoot Windows

巧了我就是萌 提交于 2019-12-23 05:32:21
问题 I have scoured the web looking for solutions on how to SafeBoot into Windows using only C#. Since Vista and above, safe booting is controlled using BCD. Ofcourse you could use the commandline tool "bcdedit": bcdedit /set {current} safeboot Minimal However I do not want to use this approach. So my question is: How do I reboot into safe mode using only C#? I have already looked at this SO post, which has got me started. But I'm still missing pieces to this puzzle. Any help is greatly

How to create/insert WMI object?

倖福魔咒の 提交于 2019-12-23 05:14:18
问题 I'm doing a software that manages the Windows power plans in C#, and to get the Power Plans and set it's settings is easy by the ManagementObjet. But I want to create a new Power Plan, in other words, create a new WMI object, and I don't know how to do that. Do any one knows how to create it? 回答1: You can't do this in WMI. You can use the Win32 APIs for Power Scheme Management as described here to create your plan, and then monitor/manage it using WMI. To create a power scheme, you need to

How to get WMI object from a WMI object reference?

痴心易碎 提交于 2019-12-23 04:41:19
问题 Similar to this question except that no answer was given with regards to the main question of getting an object from reference. For example: PS C:\Users\admin> Get-WmiObject -Namespace $namespace -Class $class ... IsActive : 1 oA: \\.\ROOT\abc\abc\ABC:abc.xyz="tst2" oB : \\.\ROOT\abc\abc\ABC:abc.xyz="tst3" PSComputerName : admin-test2 oA and oB are references and therefore come up as strings in powershell. Is there a way I can get the object they represent using WMI query in powershell? 回答1:

Determining who is accessing a file on a shared folder in Windows 2008 R2 server / Windows 7

江枫思渺然 提交于 2019-12-23 03:51:50
问题 I need to find a way to determine what files on a shared folder are being accessed, and by whom. Commands like "Net Files" and "Net Session" can give this information, as well as PSFile.exe in SysInternals, but I cannot figure out how to do this programmatically. I have found a way to determine who is accessing a share via WMI, but it does not show what file is being accessed. Does anyone know how to do this in C / C++ / C#? Any and all help will be greatly appreciated. 回答1: NetFileEnum level

how do i use another identity to execute my code in asp.net provided i have a username and password

Deadly 提交于 2019-12-23 03:45:16
问题 I'm building a small web based management app. Within it I need to connect to different servers using different accounts via wmi. What I want is to tell my app: you are now run by user1, do this and this. And then I want to tell it: now you are user2, do this and this. I guess, I'm not all that clear with my question, I'll refactor it. 回答1: You would have to write a seperate piece of .Net code (some umanaged calls too) to perform impersonation of your user then call your code whilst

how to check if hard drive is eide or sata with powershell

北战南征 提交于 2019-12-23 03:38:10
问题 I like to know if there is any win32 class that can detect if a hard drive is eide or sata. Thanks in advance. 回答1: There is no straight way to find that. However, you can use the caption property of Win32_DiskDrive and parse it to see if you have a ATA or SCSI disk. On my system, SATA disk has a caption ST9500420AS ATA Device . The way you do this is: Get-WMIObject -Class Win32_DiskDrive | Select Caption, Index You can parse the Caption property to find if it contains ATA or SCSI. 回答2: As

Access denied when reading / writing to network location as a remote process

时光毁灭记忆、已成空白 提交于 2019-12-23 03:18:11
问题 I'm currently trying to launch a process on a remote machine using WMI in C#. The process reads and writes to a file that is stored on a separate server. When I manually login to the remote machine, I can run the process and it all works fine. However, when I try to launch the process on the remote from my local machine using WMI, I get the following error: System.UnauthorizedAccessException: Access to the path '\\server\path\input.txt' is denied. I've tried multiple connection options, but I

WMI Win32_Process.Create fails with Insufficient Privs

喜欢而已 提交于 2019-12-23 02:53:33
问题 I'm trying to run a simple cmd utility on a remote Windows server from within a vbscript by invoking the Win32_Process class, like so: serverIP = "10.0.0.3" Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & serverIP & "\root\cimv2:Win32_Process") RunCommand = "cmd.exe /c echo hello >c:\hello.txt" wscript.echo RunCommand intReturn = oWMI.Create(RunCommand, Null, Null, intProcessID) wscript.echo intReturn Select Case intReturn Case 0 Wscript.Echo "Successful" Case 2 Wscript

Remotely extend a partition using WMI

谁说我不能喝 提交于 2019-12-22 17:56:51
问题 I'm trying to use PowerShell and WMI to remotely extend a C drive partition on Windows VMs running on VMware. These VM do not have WinRM enabled and that's not an option. What I'm trying to do is an equivalent of remotely managing an Active Directory computer object in an AD console to extend a partition, but in PowerShell. I'v already managed to pull partition informations through Win32 WMI objects but not yet the extension part. Does anyone know how to max out a C partition on a drive like