WMI ~ Obtener Información Del Sistema

Esta sección es para compartir scripts, librerías y herramientas.

Moderator: Flipeador

User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

WMI ~ Obtener Información Del Sistema

10 Dec 2014, 21:28

Obtener Informacón Del Sistema Con AutoHotKey

Image

ImageComputadora - General
Spoiler
Image


ImageComputadora - Producto Del Sistema
Spoiler
Image


ImageSistema Operativo: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Spoiler
Image


ImageInformación Del Usuario
Spoiler
Image


ImageMouse
Spoiler
Image


ImageEscritorio
Spoiler
Image


ImageBIOS: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Spoiler
Image


ImageAdaptador De Red
Spoiler
Image


ImageMonitor
Spoiler
Image


ImageMemoria Física: msdn.microsoft.com/en-us/library/aa3943 ... 85%29.aspx
Spoiler
Image


ImageDispositivo De Audio: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Spoiler
Image


ImageMemoria Caché
Spoiler
Image


ImageBUS
Spoiler
Image


ImageProcesador: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Spoiler
Image


ImageControlador De Video: msdn.microsoft.com/en-us/library/aa3945 ... 85%29.aspx
Spoiler
Image


ImageControlador USB: msdn.microsoft.com/en-us/library/aa3945 ... 85%29.aspx
Spoiler
Image


ImageAntivirus / Antimalware
Spoiler
ImageFirewall
Spoiler
Image


ImageUnidad De CDROM
Spoiler
Image


ImagePING
Spoiler
Image


ImagePlaca Madre, Placa Base, MoBo o Motherboard: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Spoiler

Image


ImageAdministrar Servicios: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Spoiler
Image

Funciones Apartes:
Spoiler
Continuara ..

Image

Otros Enlaces Referidos: AHK - WMI - Snippets (jNizM) | Common WMI task (tank)
Last edited by Flipeador on 24 Dec 2014, 08:06, edited 8 times in total.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: WMI ~ Obtener Información Del Sistema

11 Dec 2014, 05:01

I do not understand spanish but I see you use some old code from me =)
So if I can give you a tip: this is a better way to work with wmi =)

Code: Select all

Win32_ComputerSystemProduct := {}
for objItem in ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
{
    Win32_ComputerSystemProduct.Caption              := objItem.Caption
    Win32_ComputerSystemProduct.Description          := objItem.Description
    Win32_ComputerSystemProduct.IdentifyingNumber    := objItem.IdentifyingNumber
    Win32_ComputerSystemProduct.Name                 := objItem.Name
    Win32_ComputerSystemProduct.SKUNumber            := objItem.SKUNumber
    Win32_ComputerSystemProduct.UUID                 := objItem.UUID
    Win32_ComputerSystemProduct.Vendor               := objItem.Vendor
    Win32_ComputerSystemProduct.Version              := objItem.Version
}

MsgBox % Win32_ComputerSystemProduct.UUID
reflink: WMI & for loops
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
Flipeador
Posts: 1204
Joined: 15 Nov 2014, 21:31
Location: Argentina
Contact:

Re: WMI ~ Obtener Información Del Sistema

11 Dec 2014, 07:38

jNizM wrote:I do not understand spanish but I see you use some old code from me =)
So if I can give you a tip: this is a better way to work with wmi =)

Code: Select all

Win32_ComputerSystemProduct := {}
for objItem in ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
{
    Win32_ComputerSystemProduct.Caption              := objItem.Caption
    Win32_ComputerSystemProduct.Description          := objItem.Description
    Win32_ComputerSystemProduct.IdentifyingNumber    := objItem.IdentifyingNumber
    Win32_ComputerSystemProduct.Name                 := objItem.Name
    Win32_ComputerSystemProduct.SKUNumber            := objItem.SKUNumber
    Win32_ComputerSystemProduct.UUID                 := objItem.UUID
    Win32_ComputerSystemProduct.Vendor               := objItem.Vendor
    Win32_ComputerSystemProduct.Version              := objItem.Version
}

MsgBox % Win32_ComputerSystemProduct.UUID
reflink: WMI & for loops
Hello, jNizM. Thank you very much for your tips, are helpful.
On the subject, yes, I think have gotten some information about a topic yours, sorry if that bothered him was not my intention, I think I saw a topic him to guide me and had changed a little, I had a while ago . I just put a link to your topic = D.
I just updated the theme guiding me for the link that left me, Again, Thanks jNizM
Greetings! ..


-------------------------------------------

Con DllCall:

Code: Select all

Class Sys {
	
	;apagar
	;Sinraxis: Shutdown( [Código] )
	;CÓDIGOS
		;1 = Apagar | 0 = Cerrar sesion | 2 = Reiniciar | 8 = Power down | Forzar = +4
		;20 = Suspender | 21 = Hibernar
		;30 = Apagar monitor | 31 = Encender monitor
	Shutdown(Code) {
		if Code in 20,21 ;Suspend/Hibernate
			return DllCall("PowrProf.dll\\SetSuspendState", "int", Code = 20 ? 0 : 1, "int", 0, "int", 0)
		if Code in 30,31 ;Turn monitor On/Off
		{
			SendMessage, 0x112, 0xF170, % Code = 30 ? 2 : -1,, Program Manager
			return !ErrorLevel
		}
		Shutdown, %Code%
		return !ErrorLevel
	}
	
	;informacion de la placa madre
	Win32_BaseBoard() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_BaseBoard")
	}
	
	;informacion del controlador USB
	Win32_USBController() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_USBController")
	}
	
	;informacion del cotrolador de video
	Win32_VideoController() {
		i := {}
		for v in ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM CIM_VideoController") {
			i.Ram := i.Ram ? i.Ram : Round(v.AdapterRAM / (1024 ** 2), 1) ;memoria de video (VRAM), en megabytes
			i.Name := i.Name ? i.Name : v.Name ;nombre
		}
		return i
	}
	
	;informacion del procesador
	Win32_Processor() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_Processor")
	}
	
	;informacion del BUS
	Win32_Bus() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_Bus")
	}
	
	;informacion de la memoria cache
	Win32_CacheMemory() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_CacheMemory")
	}
	
	;informacion de memoria
	Win32_PhysicalMemory() {
		ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_PhysicalMemory")
	}
	
	;informacion de RED
	Win32_NetworkAdapterConfiguration() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration")
	}
	
	;informacion de BIOS
	Win32_BIOS() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_BIOS")
	}
	
	;informacion del escritorio
	Win32_Desktop() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_Desktop")
	}
	
	;informacion del systema
	Win32_OperatingSystem() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem")
	}
	
	;producto del systema
	Win32_ComputerSystemProduct() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
	}
	
	;informacion general
	Win32_ComputerSystem() {
		return ComObjGet("winmgmts:\\.\root\CIMV2").ExecQuery("SELECT * FROM Win32_ComputerSystem")
	}
	
	BiosDate() {
		RegRead, bd, HKLM\SYSTEM\CurrentControlSet\Control\Biosinfo, SystemBiosDate
		return bd
	}
	
	;dispositivo de arranque
	BootDevice() {
		RegRead, bd, HKLM\SYSTEM\CurrentControlSet\Control, SystemBootDevice
		return bd
	}
	
	;opciones de inicio
	StartOptions() {
		RegRead, so, HKLM\SYSTEM\CurrentControlSet\Control, SystemStartOptions
		return so
	}
	
	;obtener ruta de carpetas especiales
	ShellFolders(SF) {
		RegRead, SF, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, %SF%
		if !SF OR ErrorLevel
			RegRead, SF, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, %SF%
		if !SF OR ErrorLevel
			RegRead, SF, HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, %SF%
		return SF
	}

	;porcentaje de uso de CPU
	CPULoad() { ; By SKAN, http://ahkscript.org/boards/viewtopic.php?f=6&t=3413
		Static PIT, PKT, PUT
		if (PIT = "")
			return 0, DllCall("Kernel32.dll\GetSystemTimes", "Int64P", PIT, "Int64P", PKT, "Int64P", PUT)
		DllCall("Kernel32.dll\GetSystemTimes", "Int64P", CIT, "Int64P", CKT, "Int64P", CUT )
			, IdleTime := PIT - CIT, KernelTime := PKT - CKT, UserTime := PUT - CUT, SystemTime := KernelTime + UserTime
		Return ((SystemTime - IdleTime) * 100) // SystemTime, PIT := CIT, PKT := CKT, PUT := CUT
	}

	;Recupera un identificador de la ventana del escritorio. La ventana del escritorio cubre toda la pantalla, es el área sobre la cual otras ventanas están pintadas.
	DesktopWindow() {
		return DllCall("User32.dll\GetDesktopWindow")
	}
	
	;Recupera la ruta a la raíz del directorio del usuario actual
	UserProfile() {
		return This.ProfilesPath() "\" This.UserName(2, 0)
	}
	
	;Recupera la ruta a la raíz del directorio que contiene los datos del programa compartidos por todos los usuarios.
	AllUsersProfile() {
		uSize := VarSetCapacity(lpBuffer, 261 * 2)
		DllCall("Userenv.dll\GetAllUsersProfileDirectory", "Ptr", &lpBuffer, "UInt*", 261)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}
	
	;Recupera la ruta de acceso al directorio raíz donde se almacenan los perfiles de usuario.
	ProfilesPath() {
		uSize := VarSetCapacity(lpBuffer, 261 * 2)
		DllCall("Userenv.dll\GetProfilesDirectoryW", "Ptr", &lpBuffer, "UInt*", 261)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}
	
	;Recupera la ruta de acceso a la raíz del perfil de usuario predeterminado.
	DefaultUserProfile() {
		uSize := VarSetCapacity(lpBuffer, 261 * 2)
		DllCall("Userenv.dll\GetDefaultUserProfileDirectoryW", "Ptr", &lpBuffer, "UInt*", 261)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}
	
	;Recupera la fecha local actual y la hora.
	;EJEMPLO:
		;LT := Sys.LocalTime()
		;MsgBox % LT.Day "/" LT.Mon "/" LT.Year
	LocalTime(Type := "Local") { ;https://msdn.microsoft.com/en-us/library/ms724950.aspx
		VarSetCapacity(lpSystemTime, 16, 0), NumPut(16, lpSystemTime, "UShort")
		DllCall("kernel32.dll\Get" Type "Time", "Ptr", &lpSystemTime)
		i := {}, i.Year := NumGet(lpSystemTime, 0, "UShort") ;año = Year
			, i.Mon := NumGet(lpSystemTime, 2, "UShort") ;mes = Mon
			, i.Day := NumGet(lpSystemTime, 6, "UShort") ;día  = Day
			, i.WD := NumGet(lpSystemTime, 4, "UShort") ;día de la semana = WD
			, i.Hour := NumGet(lpSystemTime, 8, "UShort") ;hora = Hour
			, i.Min := NumGet(lpSystemTime, 10, "UShort") ;minutos = Min
			, i.Sec := NumGet(lpSystemTime, 12, "UShort") ;segundos = Seg
			, i.MS := NumGet(lpSystemTime, 14, "UShort") ;milisegundos = MS
		return i
	}

	;Recupera la fecha actual del sistema y el tiempo. La hora del sistema se expresa en hora universal coordinada (UTC).
	;EJEMPLO: ver LocalTime()
	SystemTime() { ;https://msdn.microsoft.com/en-us/library/ms724390.aspx
		return This.LocalTime("System")
	}
	
	;Recupera el nombre del usuario o de otra entidad de seguridad asociado con el subproceso de llamada. Puede especificar el formato del nombre devuelto.
	;https://msdn.microsoft.com/en-us/library/ms724268.aspx
	;Sinstaxis: UserName( [formato], [0 | 1] )
	;EJEMPLO: MsgBox % Sys.UserName(2, 1) "`n" Sys.UserName(2, 0)
	UserName(NameFormat := 2, IpName := 1) {
		if (IpName) {
			uSize := VarSetCapacity(lpBuffer, 1023, 0) + 1
			DllCall("Secur32.dll\GetUserNameExW", "UInt", NameFormat, "Ptr", &lpBuffer, "UInt*", uSize)
			return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
		}
		uSize := VarSetCapacity(lpBuffer, 256, 0) + 1
		DllCall("Advapi32.dll\GetUserName", "Ptr", &lpBuffer, "UInt*", uSize)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}
	
	;Recupera el tamaño actual del registro y el tamaño máximo que se permite el registro de alcanzar en el sistema (MB).
	RegistryQuota(i := " MB || ", d := " MB") {
		DllCall("Kernel32.dll\GetSystemRegistryQuota", "UInt*", pdwQuotaAllowed, "UInt*", pdwQuotaUsed)
		return Round(pdwQuotaUsed / (1024 ** 2), 2) i Round(pdwQuotaAllowed / (1024 ** 2), 2) d
	}

	;Recupera el nombre NetBIOS del equipo local. Este nombre se estableció al inicio del sistema, cuando el sistema lo lee desde el registro.
	ComputerName() {
		uSize := VarSetCapacity(lpBuffer, 64, 0)
		DllCall("kernel32.dll\GetComputerName", "Ptr", &lpBuffer, "UInt*", uSize)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}

	;Recupera la ruta del directorio de sistema utilizado por WOW64. Este directorio no está presente en Windows de 32 bits.
	SystemWow64Path() {
		uSize := VarSetCapacity(lpBuffer, 260, 0)
		DllCall("kernel32.dll\GetSystemWow64DirectoryW", "Ptr", &lpBuffer, "UInt", uSize)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}

	;Recupera la ruta del directorio de sistema. El directorio del sistema contiene los archivos del sistema, como las bibliotecas y los controladores de vínculos dinámicos.
	;Ejemplo: C:\Windows\System32
	SystemPath() {
		uSize := VarSetCapacity(lpBuffer, 260, 0)
		DllCall("kernel32.dll\GetSystemDirectory", "Ptr", &lpBuffer, "UInt", uSize)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}

	;Recupera la ruta de acceso del directorio de Windows.
	;Ejemplo: C:\Windows
	WindowsPath() {
		uSize := VarSetCapacity(lpBuffer, 260, 0)
		DllCall("kernel32.dll\GetWindowsDirectoryW", "Ptr", &lpBuffer, "UInt", uSize)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}
	
	;Recupera la ruta del directorio compartido de Windows en un sistema multi-usuario.
	SystemWindowsPath() {
		uSize := VarSetCapacity(lpBuffer, 260, 0)
		DllCall("kernel32.dll\GetSystemWindowsDirectoryW", "Ptr", &lpBuffer, "UInt", uSize)
		return RegExReplace(StrGet(&lpBuffer, uSize, "UTF-16"), "\\+$")
	}
	
	;Archivos Temporales
	;Ejemplo: C:\DOCUME~1\Usuario\CONFIG~1\Temp
	TempPath() {
		VarSetCapacity(lpBuffer, 261 * 2)
		DllCall("kernel32.dll\GetTempPath", "UInt", 261, "Ptr", &lpBuffer)
		return RegExReplace(StrGet(&lpBuffer), "\\+$")
	}

	;Recupera información sobre el uso actual del sistema de memoria tanto física como virtual.
	;http://ahkscript.org/boards/viewtopic.php?f=7&t=406 | jNizM
	;EJEMPLO: MsgBox % Sys.GlobalMemoryStatusEx().Load " %"
	GlobalMemoryStatusEx() { ;https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589%28v=vs.85%29.aspx
		VarSetCapacity(MEMORYSTATUSEX, 64, 0), NumPut(64, MEMORYSTATUSEX, "UInt")
		DllCall("kernel32.dll\GlobalMemoryStatusEx", "Ptr", &MEMORYSTATUSEX)
		i := {}, i.Lenght := NumGet(MEMORYSTATUSEX, 0, "UInt") ; El tamaño de la estructura, en bytes
			, i.Load := NumGet(MEMORYSTATUSEX, 4, "UInt") ;número entre 0 y 100 que especifica el porcentaje aproximado de la memoria física que está en uso
			, i.TotalPhys := NumGet(MEMORYSTATUSEX, 8, "UInt64") ;cantidad de memoria física real, en bytes
			, i.AvailPhys := NumGet(MEMORYSTATUSEX, 16, "UInt64") ;cantidad de memoria física disponible actualmente, en bytes
			, i.TotalPageFile := NumGet(MEMORYSTATUSEX, 24, "UInt64") ;límite de memoria comprometida actual para el sistema o el proceso actual, en bytes
			, i.AvailPageFile := NumGet(MEMORYSTATUSEX, 32, "UInt64") ;cantidad máxima de memoria que el proceso actual puede usar, en bytes.
			, i.TotalVirtual := NumGet(MEMORYSTATUSEX, 40, "UInt64") ;El tamaño de la parte del modo usuario del espacio de direcciones virtuales del proceso de llamada, en bytes
			, i.AvailVirtual := NumGet(MEMORYSTATUSEX, 48, "UInt64") ; La cantidad de memoria sin reservas y no comprometido actualmente en la parte del modo usuario del espacio de direcciones virtuales del proceso de llamada, en bytes
			;, i.AvailExtendedVirtual := NumGet(MEMORYSTATUSEX, 56, "UInt64") ;Reservado. Este valor es siempre 0.
			;, i.RAM := DllCall("Kernel32.dll\GetPhysicallyInstalledSystemMemory", "UInt64*", TotalMemoryInKilobytes) ? TotalMemoryInKilobytes : (i.TotalPhys / 1024) ;cantidad de RAM instalada físicamente en el equipo, en kilobytes
		return i
	}
	
}

Return to “Scripts y Funciones”

Who is online

Users browsing this forum: No registered users and 12 guests