Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
  4.  
  5. strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  6.  
  7. strEntry1a = "DisplayName"
  8.  
  9.  
  10.  
  11. Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
  12.  
  13. Const FOR_APPENDING = 8
  14.  
  15.  
  16.  
  17. strFecha = Date()
  18.  
  19. strHora = Time()
  20.  
  21. Set objComputer = CreateObject("WScript.NetWork")
  22.  
  23. strComputer =  objComputer.ComputerName
  24.  
  25. strSN = "na"
  26.  
  27. strType = "na"
  28.  
  29.  
  30.  
  31.  
  32.  
  33. Function FindUser(ByVal UserName, Byval Domain)
  34.  
  35.     on error resume Next
  36.  
  37.  
  38.  
  39.     set cn = createobject("ADODB.Connection")
  40.  
  41.     set cmd = createobject("ADODB.Command")
  42.  
  43.     set rs = createobject("ADODB.Recordset")
  44.  
  45.  
  46.  
  47.     cn.open "Provider=ADsDSOObject;"
  48.  
  49.    
  50.  
  51.     cmd.activeconnection=cn
  52.  
  53.     cmd.commandtext="SELECT ADsPath FROM 'LDAP://" & Domain & _
  54.  
  55.              "' WHERE sAMAccountName = '" & UserName & "'"
  56.  
  57.    
  58.  
  59.     set rs = cmd.execute
  60.  
  61.  
  62.  
  63.     if err<>0 then
  64.  
  65.         FindUser="Error connecting to Active Directory Database:" & err.description
  66.  
  67.     else
  68.  
  69.         if not rs.BOF and not rs.EOF then
  70.  
  71.                 rs.MoveFirst
  72.  
  73.                 FindUser = rs(0)
  74.  
  75.         else
  76.  
  77.             FindUser = "Not Found"
  78.  
  79.         end if
  80.  
  81.     end if
  82.  
  83.     cn.close
  84.  
  85. end Function
  86.  
  87.  
  88.  
  89.  
  90.  
  91. Function GetType (ByVal computerName)
  92.  
  93. On Error Resume Next
  94.  
  95.     If InStr (computerName,"WN")=0 Then
  96.  
  97.         GetType = DESKTOP
  98.  
  99.         Else
  100.  
  101.         GetType = NOTEBOOK
  102.  
  103.     End If
  104.  
  105. End Function
  106.  
  107.  
  108.  
  109.  
  110.  
  111. 'Obtenemos la(s) IP(s)
  112.  
  113. Set objWMIService = GetObject("winmgmts:" _
  114.  
  115.     & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  116.  
  117.  
  118.  
  119. Set IPConfigSet = objWMIService.ExecQuery _
  120.  
  121.     ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
  122.  
  123.  
  124.  
  125. For Each IPConfig in IPConfigSet
  126.  
  127.     If Not IsNull(IPConfig.IPAddress) Then
  128.  
  129.         For i=LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
  130.  
  131.             If IPConfig.IPAddress(i) <> "0.0.0.0" then
  132.  
  133.             strIPs=strIPs & " " & IPConfig.IPAddress(i)
  134.  
  135.             End if
  136.  
  137.         Next
  138.  
  139.     End If
  140.  
  141. Next
  142.  
  143.  
  144.  
  145. strLogPath = "\\2.13.76.31\deploy\inventory2011_dsc.xls"
  146.  
  147.  
  148.  
  149. 'Sacamos informacion de Marca y modelo
  150.  
  151. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  152.  
  153. Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
  154.  
  155. For Each objItem In colItems
  156.  
  157.  
  158.  
  159.   strManufacturer = objItem.Manufacturer
  160.  
  161.   strModel = objItem.Model
  162.  
  163.   strRAM = objItem.TotalPhysicalMemory
  164.  
  165.   Next
  166.  
  167.  
  168.  
  169. 'Sacamos informacion de SerialNumber
  170.  
  171. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
  172.  
  173. Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct")
  174.  
  175. For Each objItem In colItems
  176.  
  177. strSN = objItem.IdentifyingNumber
  178.  
  179. Next
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187. 'Sacamos el tipo de CPU
  188.  
  189. Set objWMIService = GetObject("winmgmts:" _
  190.  
  191.    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  192.  
  193. Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
  194.  
  195.  
  196.  
  197. For Each objItem in colItems
  198.  
  199. strCPU = objItem.Name
  200.  
  201. Next
  202.  
  203.  
  204.  
  205. 'Sacamos datos de SO
  206.  
  207. Set colOperatingSystems = objWMIService.ExecQuery _
  208.  
  209.     ("Select * from Win32_OperatingSystem")
  210.  
  211. For Each objOperatingSystem In colOperatingSystems
  212.  
  213. strOsver = objOperatingSystem.Version
  214.  
  215. strSP =objOperatingSystem.ServicePackMajorVersion
  216.  
  217. strOSInstallDate= objOperatingSystem.InstallDate
  218.  
  219.  
  220.  
  221. Next
  222.  
  223.  
  224.  
  225. 'Sacamos datos del usuario
  226.  
  227.     strADPath=FindUser(objComputer.UserName,"prg-dc.dhl.com")
  228.  
  229.     On Error Resume Next
  230.  
  231.      Set objUser = GetObject _
  232.  
  233.      (strADPath)
  234.  
  235.       strEmail= objUser.userPrincipalName
  236.  
  237.       strDisplayName= objUser.displayName
  238.  
  239.  
  240.  
  241. 'Comprobamos si tiene kea instalado
  242.  
  243.  
  244.  
  245. Set objReg = GetObject("winmgmts://" & strComputer & _
  246.  
  247.  "/root/default:StdRegProv")
  248.  
  249. objReg.EnumKey HKLM, strKey, arrSubkeys
  250.  
  251. strKeaInstalled = "NONE"
  252.  
  253. strTinyInstalled = "NONE"
  254.  
  255.  
  256.  
  257. For Each strSubkey In arrSubkeys
  258.  
  259.   intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
  260.  
  261.    strEntry1a, strValue1)
  262.  
  263.   If intRet1 <> 0 Then
  264.  
  265.     objReg.GetStringValue HKLM, strKey & strSubkey, _
  266.  
  267.      strEntry1b, strValue1
  268.  
  269.   End If
  270.  
  271.   If strValue1 <> "" Then
  272.  
  273.     If InStr (strValue1,"KEAVT")=0 Then
  274.  
  275.        Else
  276.  
  277.        strKeaInstalled = "YES"
  278.  
  279.      End If  
  280.  
  281.    
  282.  
  283.     If InStr (strValue1,"Tiny")=0 Then
  284.  
  285.        Else
  286.  
  287.        strTinyInstalled = "YES"
  288.  
  289.      End If  
  290.  
  291.  
  292.  
  293.   End If
  294.  
  295. Next
  296.  
  297. 'Preparamos el fichero de log
  298.  
  299.    
  300.  
  301.  
  302.  
  303. strContent=strComputer & vbTab & strManufacturer & vbTab & strModel & vbTab & strSN & vbTab & strIPs & vbTab & strCPU &vbTab& strRAM &vbTab& objComputer.UserDomain & vbTab & objComputer.UserName & vbTab
  304.  
  305. strContent=strContent & strDisplayName & vbTab &  strEmail & vbTab
  306.  
  307. strContent=strContent & strOsver &vbTab& strSP &vbTab& strOSInstallDate &vbTab& strFecha &vbTab& strKeaInstalled & vbTab & strTinyInstalled & vbLf
  308.  
  309.  
  310.  
  311. ' Escribimos en el fichero
  312.  
  313. Set objFS = CreateObject("Scripting.FileSystemObject")
  314.  
  315. On Error Resume Next
  316.  
  317. Set objTS = objFS.OpenTextFile(strLogPath,FOR_APPENDING)
  318.  
  319. On Error Resume Next
  320.  
  321. objTS.Write strContent
  322.  
  323. On Error Resume Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement