03/11/2004, 04:41
|
| | Fecha de Ingreso: octubre-2004
Mensajes: 15
Antigüedad: 20 años, 1 mes Puntos: 0 | |
Y aqui paso algunas funciones de WMI (Windows Management Instrumentation). Tienes que tener unas variables globales, llamadas WMIUSER, WMISERVER y WMIPASSWD (El usuario y password deben de tener permisos en las maquinas destino.)
Devuelve el nombre de la maquina si introduces una IP en WMIServer
Código:
Function Nombre()
Dim objLocator, objService, objInstance, item
Nombre = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select caption from win32_computersystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
Nombre = Nombre & item.caption & "|"
Next
Nombre = Left(Nombre,Len(Nombre)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Devuelve la Marca de la maquina
Código:
Function Marca()
Dim objLocator, objService, objInstance, item
Marca = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select manufacturer from win32_computersystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
Marca = Marca & item.manufacturer & "|"
Next
Marca = Left(Marca,Len(Marca)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Devuelve el modelo de la maquina
Código:
Function Modelo()
Dim objLocator, objService, objInstance, item
Modelo = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select model from win32_computersystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
Modelo = Modelo & item.model & "|"
Next
Modelo = Left(Modelo,Len(Modelo)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Devuelve el numero de CPUS
Código:
Function NumCPUS()
Dim objLocator, objService, objInstance, item
NumCPUS = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select numberofprocessors from win32_computersystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
NumCPUS = NumCPUS & item.numberofprocessors & "|"
Next
NumCPUS = Left(NumCPUS,Len(NumCPUS)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Devolver el Sistema Operativo
Código:
Function SistemaOperativo()
Dim objLocator, objService, objInstance, item
SistemaOperativo = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select Caption from win32_operatingsystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
SistemaOperativo = SistemaOperativo & item.Caption & "|"
Next
SistemaOperativo = Left(SistemaOperativo, Len(SistemaOperativo)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Devolver el Service Pack del Sistema Operativo
Código:
Function ServicePack()
Dim objLocator, objService, objInstance, item
ServicePack = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select ServicePackMajorVersion, ServicePackMinorVersion from win32_operatingsystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
ServicePack = ServicePack & item.ServicePackMajorVersion & "." & item.ServicePackMinorVersion & "|"
Next
ServicePack = Left(ServicePack, Len(ServicePack)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Idioma del Sistema Operativo
Código:
Function Idioma()
Dim objLocator, objService, objInstance, item
Idioma = ""
if WMIServer = "" then Exit Function
Set objLocator = Server.CreateObject("WbemScripting.sWbemLocator")
Set objService = objLocator.ConnectServer(WMIServer,"root\cimv2",WMIUser,WMIPasswd)
Query = "select oslanguage from win32_operatingsystem"
Set objInstance = objService.ExecQuery(query)
For Each item In objInstance
Idioma = Idioma & NombreIdioma(Hex(item.oslanguage)) & "|"
Next
Idioma = Left(Idioma, Len(Idioma)-1)
Set objInstance = Nothing
Set objService = Nothing
Set objLocator = Nothing
End Function
Private Function NombreIdioma(value)
Dim dictLang
Set dictLang = Server.CreateObject("Scripting.Dictionary")
dictLang.Add "409","Ingles (US)"
dictLang.add "809","Ingles (Britanico)"
dictLang.Add "1009","Ingles (Canada)I"
dictLang.Add "1409","Ingles (Nueva Zelanda)"
dictLang.Add "0c09","Ingles (Australia)"
dictLang.Add "1809","Ingles (Irlanda)"
dictLang.Add "1c09","Ingles (America del Sur)"
dictLang.Add "2009","Ingles (Jamaica)"
dictLang.Add "2409","Ingles (Caribe)"
dictLang.Add "40c","Frances (Estandard)"
dictLang.Add "80c","Frances (Belgica)"
dictLang.Add "100c","Frances (Suiza)"
dictLang.Add "c0c","Frances (Canada)"
dictLang.Add "140c","Frances (Luxemburgo)"
dictLang.Add "407","Aleman (Estandard)"
dictLang.Add "807","Aleman (Suiza)"
dictLang.Add "c07","Aleman (Austria)"
dictLang.Add "1007","Aleman (Luxemburgo)"
dictLang.Add "1407","Aleman (Liechtenstein)"
dictLang.Add "411","Japones"
dictLang.Add "80a","Español (Mejico)"
dictLang.Add "40a","Español (Tradicional)"
dictLang.Add "c0a","Español (Moderno)"
NombreIdioma = dictLang.Item(lcase(cstr(value)))
Set dictLang = Nothing
End Function
Espero que sean de utilidad |