2015年2月14日 星期六

Get PCIe link speed (on Win server 2012) - wmic command

Because lspci can't run on win server 2012, so I tried to find another solution. And finally I find solution from microsoft.

wmic /namespace:\\root\StandardCimv2 path MSFT_NetAdapterHardwareInfoSettingData get Caption, PciExpressCurrentLinkSpeedEncoded /format:list




Reference: https://msdn.microsoft.com/en-us/library/hh872354(v=vs.85).aspx

2015年1月13日 星期二

用wmic + class撈資料

wmic path Win32_DisplayConfiguration get /format:list

wmic path Win32_VideoController get /format:list

wmic /namespace:\\root\CIMV2 path VideoControllerResolution get /format:list

https://msdn.microsoft.com/en-us/library/aa388669(v=vs.85).aspx

http://msdn.microsoft.com/en-us/library/aa394137(v=vs.85).aspx

Gathering WMI Data without Writing a Single Line of Code

http://technet.microsoft.com/en-us/magazine/2006.09.wmidata.aspx

Win32_DisplayConfiguration - WMI sample in VBScript

VBScript

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DisplayConfiguration",,48)
For Each objItem in colItems
    Wscript.Echo "BitsPerPel: " & objItem.BitsPerPel
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DeviceName: " & objItem.DeviceName
    Wscript.Echo "DisplayFlags: " & objItem.DisplayFlags
    Wscript.Echo "DisplayFrequency: " & objItem.DisplayFrequency
    Wscript.Echo "DitherType: " & objItem.DitherType
    Wscript.Echo "DriverVersion: " & objItem.DriverVersion
    Wscript.Echo "ICMIntent: " & objItem.ICMIntent
    Wscript.Echo "ICMMethod: " & objItem.ICMMethod
    Wscript.Echo "LogPixels: " & objItem.LogPixels
    Wscript.Echo "PelsHeight: " & objItem.PelsHeight
    Wscript.Echo "PelsWidth: " & objItem.PelsWidth
    Wscript.Echo "SettingID: " & objItem.SettingID
    Wscript.Echo "SpecificationVersion: " & objItem.SpecificationVersion
Next
Reference: http://www.activexperts.com/admin/scripts/wmi/vbscript/0055/

5/22 updated:
win32api_EnumDisplaySettings
http://stackoverflow.com/questions/1225057/how-can-i-determine-the-monitor-refresh-rate

2014年12月16日 星期二

PySide and pyuic

cd C:\Python27\Lib\site-packages\PySide\scripts

python uic TestGUI.ui -o TestGUI.py

2014年10月22日 星期三

Windows command line (or .bat) 跳脫字元

在bat中要輸出">"時,要在前面加上"^"
echo ping 127.0.0.1 ^> nul > 123.bat

要輸出"%"時,要在前面加上"%"

echo %%~dp0 > 123.bat

Using batch parameters (command line 參數 傳遞 bat)

Using batch parameters

The following table lists the modifiers you can use in expansion.
ModifierDescription
%~1
Expands %1 and removes any surrounding quotation marks ("").
%~f1
Expands %1 to a fully qualified path name.
%~d1
Expands %1 to a drive letter.
%~p1
Expands %1 to a path.
%~n1
Expands %1 to a file name.
%~x1
Expands %1 to a file extension.
%~s1
Expanded path contains short names only.
%~a1
Expands %1 to file attributes.
%~t1
Expands %1 to date and time of file.
%~z1
Expands %1 to size of file.
%~$PATH:1
Searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found, this modifier expands to the empty string.
The following table lists possible combinations of modifiers and qualifiers that you can use to get compound results.
ModifierDescription
%~dp1
Expands %1 to a drive letter and path.
%~nx1
Expands %1 to a file name and extension.
%~dp$PATH:1
Searches the directories listed in the PATH environment variable for %1 and expands to the drive letter and path of the first one found.
%~ftza1
Expands %1 to a dir-like output line.

Note
In the previous examples, you can replace %1 and PATH with other batch parameter values.
The %* modifier is a unique modifier that represents all arguments passed in a batch file. You cannot use this modifier in combination with the %~ modifier. The %~ syntax must be terminated by a valid argument value.

You cannot manipulate batch parameters in the same manner that you can manipulate environment variables. You cannot search and replace values or examine substrings. However, you can assign the parameter to an environment variable, and then manipulate the environment variable.

Reference:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true
http://windowsitpro.com/article/server-management/how-do-i-pass-parameters-to-a-batch-file--13443