wmic

How to get File version in variable using .cmd

本小妞迷上赌 提交于 2019-12-08 02:54:16
I used wmic to get the version of a EXE stored in a variable. It works fine when I execute it from CMD (that I ran as Admin) but when executed either in a .cmd or .bat files (even when ran as admin) the variable is not populated. This works directly in CMD: set "npver="&for /F "tokens=2delims==" %a in ('wmic datafile where "Name='c:\\Windows\\System32\\notepad.exe'" get version /format:list') do set "npver=%a" When I created the .cmd file, I doubled the % signs. You forgot to echo the variable with the command echo %npver% With Command line : set "npver="&for /F "tokens=2delims==" %a in ('wmic

Get product name from WMIC for a variable in batch

假装没事ソ 提交于 2019-12-07 13:59:39
问题 I've been struggling to get a specific output using WMIC in batch in order to build an automatic uninstall script. The issue I'm running across is that the uninstaller for the application I'm trying to remove is created under an auto-generated SSID on each system (e.g.: C:\ProgramData{07BFF8FA-C12F-46C7-8239-8EE83E21B5DA}\program-name\Uninstall.exe). Because of this, I can't build a static uninstall location based on the registry as the uninstaller string also is under the same SSID in the

Can a wmic processes table (within the command prompt window) be sorted by a value?

走远了吗. 提交于 2019-12-07 13:41:41
问题 I've been exploring various options, such as the /format flag, however it appears that sorting is only possible in XML or HTML output. I would like to sort within command prompt itself. It seems that even TaskList cannot do this (and I would prefer to use wmic since it seems to perform faster). An example of a command to run would be wmic process get name,processid,workingsetsize . Processes appear to be sorted by processid, but it would make much more sense (in my use case, at least) to sort

WMIC Returning Odd Serial Number

人走茶凉 提交于 2019-12-07 04:37:00
问题 I have an odd issue. I'm attempting to return the hard drive serial number from WMIC to a variable in a batch file; the line that gives me the variable is: for /f "skip=2 tokens=2 delims=," %%a in ('wmic diskdrive get serialnumber /FORMAT:CSV') do (set harddisk=%%a) This assigns what wmic sees as the serial number for the hard drive to a variable, the issue is that the serial number it returns is slightly off. In one example it returns: 3ZVT01H4 But the serial number on the label is: Z3TV104H

Issue with batch file encoding

对着背影说爱祢 提交于 2019-12-06 11:15:39
问题 I have a batch file script I am trying to create to obtain some pretty basic info on the computers at my job site. However, I am having severe issues with encoding. WMIC and IPCONFIG put out different encodings, and as such, it is causing me to obtain garbled results when the commands execute. Thus far, I have: @echo off if exist "C:\%computername%-info.txt" ( echo Your computer information is already published! Skipping ) else ( ipconfig /all > "C:\%computername%-info.txt" wmic bios get

Get maximum supported resolution of all attached monitors

删除回忆录丶 提交于 2019-12-06 04:51:43
问题 I'm trying to get the maximum supported resolution of both of my monitors using WMI (since it will be part of a VBScript)I've tried the following WMI commands, but I either get a wrong result or only get info for one monitor. C:\>wmic path win32_videocontroller get videomodedescription /format:list VideoModeDescription=1366 x 768 x 4294967296 colors C:\>wmic path win32_displaycontrollerconfiguration get videomode /format:list VideoMode=1024 by 768 pixels, True Color, 60 Hertz According to

Powershell get-item VersionInfo.ProductVersion incorrect / different than WMI

一个人想着一个人 提交于 2019-12-06 02:30:01
问题 I'm trying to understand why Powershell would get back a different version number for a DLL file than what both the file properties page from Windows Explorer, and a WMI query shows. (I apologize in advance if this doesn't correctly qualify as a coding question.) The scenario: Running the following powershell command: (get-item C:\windows\system32\rdpcorekmts.dll).VersionInfo.ProductVersion This returns the following: 6.1.7600.16385 However, this version number is incorrect. When examining

Get rid of spaces and tabs in wmic output

白昼怎懂夜的黑 提交于 2019-12-06 01:03:17
Using batch, trying to get output of the following command: wmic logicaldisk get caption,description,volumename Thus, I'm simply doing the following: wmic logicaldisk get caption,description,volumename >>"C:\out.log" Unfortunately, this is the output I'm getting: The output from WMIC is unicode, your "spaces" are nulls from the two bytes unicode characters in file. Try with wmic logicaldisk get caption,description,volumename | find /v "" >>"C:\out.log" wmic has an output flag that you can use in place of redirect symbols that might work out better for you. wmic /output:"C:\out.log" logicaldisk

Get product name from WMIC for a variable in batch

旧巷老猫 提交于 2019-12-05 22:24:22
I've been struggling to get a specific output using WMIC in batch in order to build an automatic uninstall script. The issue I'm running across is that the uninstaller for the application I'm trying to remove is created under an auto-generated SSID on each system (e.g.: C:\ProgramData{07BFF8FA-C12F-46C7-8239-8EE83E21B5DA}\program-name\Uninstall.exe). Because of this, I can't build a static uninstall location based on the registry as the uninstaller string also is under the same SSID in the registry. I've tried a couple of different ways of pulling the uninstall info and the only one I've

Can a wmic processes table (within the command prompt window) be sorted by a value?

拈花ヽ惹草 提交于 2019-12-05 18:53:09
I've been exploring various options, such as the /format flag, however it appears that sorting is only possible in XML or HTML output. I would like to sort within command prompt itself. It seems that even TaskList cannot do this (and I would prefer to use wmic since it seems to perform faster). An example of a command to run would be wmic process get name,processid,workingsetsize . Processes appear to be sorted by processid, but it would make much more sense (in my use case, at least) to sort by name or memory usage ( workingsetsize ). As requested, here's an example wmic process table output: