wmi-query

Batch WMIC redirecting output and wrapping into variable

大憨熊 提交于 2019-11-28 11:45:25
I'm trying to use WMIC to remove some old printers on our older print servers if I use the below syntax from the command line it works WMIC PRINTER WHERE "SERVERNAME LIKE '%%OLDSERVERNAME%%'" DELETE I was asked to see if I could make it replace the printers or update them to spare the helpdesk from getting "how do I add my printer" calls I tried some variation with SET to set the properties for SERVERNAME, it appear to process, but nothing changes and doing a GET shows the old value still. so I figured I could do a FOR /F loop, wrap the name of the printer (sharename) in a variable and then

C++: Monitor process creation and termination in Windows

拥有回忆 提交于 2019-11-28 11:27:40
问题 I happened to see the following portion of code here. $Obj.ExecNotificationQueryAsync($hObj, "SELECT * FROM __InstanceCreationEvent WITHIN 0.5 WHERE TargetInstance ISA 'Win32_Process'") $Obj.ExecNotificationQueryAsync($hObj, "SELECT * FROM __InstanceDeletionEvent WITHIN 0.5 WHERE TargetInstance ISA 'Win32_Process'") Switch $OB.Path_.Class Case "__InstanceCreationEvent" ConsoleWrite("+~>" & _ProcessGetPath($OB.TargetInstance.ProcessID) & @CR) Case "__InstanceDeletionEvent" ConsoleWrite("!~>" &

How can I retrieve a Windows Computer's SID using WMI?

怎甘沉沦 提交于 2019-11-28 07:20:39
I'm not looking for User SIDs. I'm looking for the computer SID, which active directory would use to uniquely identify the computer. I also don't want to query the active directory server, i want to query the computer itself. (Ooh, this was a fun one! I went on a wild goose chase, as they say, trying to get the Win32_SID instance, which is a singleton and not enumerable by the usual InstancesOf or Query methods... yadda yadda yadda.) Well, it depends which computer SID you want (seriously!). There's the SID that the local computer uses for itself... For this, you just need to get the SID of

Alternative to Win32_Product?

匆匆过客 提交于 2019-11-28 02:04:39
Well, well. After playing around with querying Win32_Product to find a software version, I couldn't understand why the results were so dog-slow. As much as 15 times slower than querying Win32_service or Win32_process. So coming here to see if I'm missing something, I find that others have reported the same issue, and this article explains why. The most-often suggested alternative to finding installed software is querying a registry entry or three. That was going to be my first solution, except my company hasn't moved to configure servers to accept PSRemoting yet. Any reg queries just return

Monitor Drive. Using VB Script

家住魔仙堡 提交于 2019-11-27 16:22:42
I want to monitor a drive for file changes, using VBScript. I have the below code. It works fine for InstanceCreationEvent and InstanceDeletionEvent . But InstanceModificationEvent is not happening. From googling I got to know we need to use CIM_DataFile instead of CIM_DirectoryContainsFile to monitor InstanceModificationEvent . I am not sure how to modify the code. Can anyone help. FYI: One script should monitor all the folders and subfolders in a drive. PS: Any suggestion to improve the code and performance or other ideas also welcome. My Code: Dim arrFolders Dim strComputer Dim

How to construct WMI query

蓝咒 提交于 2019-11-27 15:09:22
I'd like to find results that Name starts with param1, and ends with param2 but my code doesn't work string wmiQuery = string.Format("SELECT CommandLine FROM Win32_Process WHERE Name LIKE '{0}%' AND Name LIKE '%{1}'", param1, param2); ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmiQuery); ManagementObjectCollection retObjectCollection = searcher.Get(); What's wrong? For comparision string wmiQuery = string.Format("SELECT CommandLine FROM Win32_Process WHERE Name LIKE '{0}%'", param1); works well Try this: string wmiQuery = string.Format("SELECT CommandLine FROM Win32

Batch WMIC redirecting output and wrapping into variable

自作多情 提交于 2019-11-27 06:27:04
问题 I'm trying to use WMIC to remove some old printers on our older print servers if I use the below syntax from the command line it works WMIC PRINTER WHERE "SERVERNAME LIKE '%%OLDSERVERNAME%%'" DELETE I was asked to see if I could make it replace the printers or update them to spare the helpdesk from getting "how do I add my printer" calls I tried some variation with SET to set the properties for SERVERNAME, it appear to process, but nothing changes and doing a GET shows the old value still. so

Query WMI remotely with PHP

无人久伴 提交于 2019-11-27 02:55:50
问题 My current code looks like this: define ( 'CPU_NAME', 'remote_server' ); $obj = new COM ( 'winmgmts:{impersonationLevel=impersonate}//' . CPU_NAME . '/root/cimv2' ); if ( is_object ( $obj ) ){ $process = $obj->execquery ( "SELECT * FROM Win32_Process" ); } Where would I put the login credentials for the remote_server? I see that it would take a username and password, but I'm not sure how to implement that. Any help would be appreciated. Reference: http://us3.php.net/manual/en/class.com.php

How can I retrieve a Windows Computer's SID using WMI?

北城以北 提交于 2019-11-27 01:47:51
问题 I'm not looking for User SIDs. I'm looking for the computer SID, which active directory would use to uniquely identify the computer. I also don't want to query the active directory server, i want to query the computer itself. 回答1: (Ooh, this was a fun one! I went on a wild goose chase, as they say, trying to get the Win32_SID instance, which is a singleton and not enumerable by the usual InstancesOf or Query methods... yadda yadda yadda.) Well, it depends which computer SID you want

Can the physical USB port be identified programmatically for a device in Windows?

女生的网名这么多〃 提交于 2019-11-26 22:52:27
问题 I have a USB device that enumerates with a different interface, VID, PID and serial number when commanded to do so, and I'd like to keep track of the physical device after this change occurs. My thought was to track it by its hub and port location. The Win32_PnPSignedDriver class has a "Location" field that seemed perfect (e.g. Port_#0001.Hub_#0010 ), but it only contains the location of the device when the driver was first loaded. Plugging the hardware into a different port does not update