1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
   |  
' ##################################################
' #														#
' #		InventaireMemoire.vsb est un script d'inventaire Machine			#
' #		Il a pour but d'effectuer l'inventaire dans un fichier Html et txt		#
' #		des informations concernant :								#
' #			- La RAM	 									#
' #			- Le fichier d'échange ou Page File (SWAP)				#
' #														#
' #		Créé le  : 17/08/2008                  			       				#
' #		Dernière modification : 17/08/2008                           				#
' #		Par : Gregory FERNANDEZ								#
' #		Version : 1.0										#
' #														#
' ##################################################
 
' Déclaration variable
Dim ComputerName, MessageOS, datetime, CountRam, CountSwap
CountRam = 0
CountSwap = 0
 
' Déclaration de variable pour l'inventaire sur la RAM
Dim MessageRAM,RAMDevice, RAMcapa, RAMtotal, RAMLabel, RAMVisible
Dim DeviceRAM(), capaRAM(), LabelRAM(), totalRAM, VisibleRAM, MasqueRAM
Redim DeviceRAM(CountRam)
Redim capaRAM(CountRam)
Redim LabelRAM(CountRam)
 
 
' Déclaration de variable pour l'inventaire sur la mémoire virtuelle
Dim MessageSwap, SwapDrive, SwapFileName, SwapPath, SwapFileSytem, SwapInitialSize, SwapMaxSize, SwapUseSize
Dim DriveSwap(), FileNameSwap(), PathSwap(), FileSytemSwap(), InitialSizeSwap(), MaxSizeSwap(), UseSizeSwap()
Redim DriveSwap(CountSwap)
Redim FileNameSwap(CountSwap)
Redim PathSwap(CountSwap)
Redim FileSytemSwap(CountSwap)
Redim InitialSizeSwap(CountSwap)
Redim MaxSizeSwap(CountSwap)
Redim UseSizeSwap(CountSwap)
 
'====================================================================================================
'	 				INFORMATION SUR LE SYSTÈME D'EXPLOITATION 				
'====================================================================================================
Sub Info_OS ()
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
	For Each objItem in colItems
 
		MachineName = objItem.CSName
		datetime = objItem.LocalDateTime
 
		'---- Convertion des date et heure locale de la machine en un format lisible par l'utilisateur. ----
		datetime = mid(datetime, 7, 2) & "/" & mid(datetime, 5, 2) & "/" & mid(datetime, 1, 4) & " - " & mid(datetime, 9, 2)& ":" & mid(datetime, 11, 2)& ":" & mid(datetime, 13, 2)
 
		MessageOS = MessageOS & Space(14) & "******************************************" & vbCrLf
		MessageOS = MessageOS & Space(28) & "Machine :" & vbCrLf 
		MessageOS = MessageOS & Space(14) & "******************************************" & vbCrLf & vbCrLf & vbCrLf
 
		MessageOS = MessageOS & FormatStrL("Nom ",30,2) & " : " & FormatStrR(MachineName,10,2) & VBCRLF	
		MessageOS = MessageOS & FormatStrL("Date et heure locale ",30,2) & " : " & FormatStrR(datetime,10,2) & VBCRLF & VBCRLF
		MessageOS = MessageOS & "===========================================================================" & Space(14) & VBCRLF & VBCRLF
 
	Next
 
End Sub		
 
 
'====================================================================================================
'	 				INFORMATION SUR LA MEMOIRE VIVE	INSTALLEE			
'====================================================================================================
' Info Memoire au format txt
Sub Info_RAM_Txt ()
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
	RAMtotal=0
 
		MessageRAM = MessageRAM & Space(14) & "******************************************" & vbCrLf
		MessageRAM = MessageRAM & Space(20) & "Mémoire Vive Installée (RAM) :" & vbCrLf 
		MessageRAM = MessageRAM & Space(14) & "******************************************" & vbCrLf & vbCrLf & vbCrLf
 
	For Each objItem in colItems
 
		RAMDevice = objItem.DeviceLocator
 
		'---- Convertion de la capcité mémoire vive installé(RAM) en un format lisible par l'utilisateur. ----
		RAMcapa=objItem.Capacity/1024/1024
		RAMtotal=RAMtotal+RAMcapa
 
		'---- Gestion de l'affichage du label de la barrette ----
		RAMLabel = objItem.BankLabel
		if RAMLabel <> "" Then
			RAMLabel = "(" & objItem.BankLabel & ")"
		end if
 
		MessageRAM = MessageRAM & FormatStrL("Barrette " & RAMDevice,17,2) & " : " & FormatStrR(RAMcapa,10,2) & Space(4) & "Mo" & Space(2) & RAMLabel & VBCRLF
 
	Next
 
		MessageRAM = MessageRAM & FormatStrL("TOTAL",17,2) &  " : " & FormatStrR(RAMtotal,10,2) & Space(4) & "Mo" & VBCRLF & VBCRLF
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
	For Each objItem in colItems
		RAMVisible=int(objItem.TotalVisibleMemorySize/1024)
 
		MessageRAM = MessageRAM & FormatStrL("RAM visible",17,2) & " : " & FormatStrR(RAMVisible,10,2) & Space(4) & "Mo" & VBCRLF
		MessageRAM = MessageRAM & FormatStrL("RAM masquée",17,2) & " : " & FormatStrR(RAMtotal-RAMVisible,10,2) & Space(4) & "Mo" & Space(2) & "(environ)" & VBCRLF & VBCRLF
		MessageRAM = MessageRAM & "===========================================================================" & Space(14) & VBCRLF & VBCRLF
	Next
End Sub
 
' Info Memoire au format html
Sub Info_RAM_html ()
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
	totalRAM=0
 
	For Each objItem in colItems
 
		DeviceRAM(CountRam) = objItem.DeviceLocator
 
		'---- Convertion de la capcité mémoire vive installé(RAM) en un format lisible par l'utilisateur. ----
		capaRAM(CountRam)=objItem.Capacity/1024/1024
		totalRAM=totalRAM+capaRAM(CountRam)
 
		'---- Gestion de l'affichage du label de la barrette ----
		LabelRAM(CountRam) = objItem.BankLabel
		if LabelRAM(CountRam) <> "" Then
			LabelRAM(CountRam) = "(" & objItem.BankLabel & ")"
		end if
 
		CountRam = CountRam+1
		Redim Preserve DeviceRAM(CountRam)
		Redim Preserve capaRAM(CountRam)	
		Redim Preserve LabelRAM(CountRam)
 
	Next
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
	For Each objItem in colItems
		VisibleRAM=int(objItem.TotalVisibleMemorySize/1024)
		MasqueRAM = totalRAM-RAMVisible		
	Next
 
End Sub
 
'====================================================================================================
'	 					INFORMATIONS MEMOIRE VIRTUELLE (PAGE FILE OU SWAP)		
'====================================================================================================
' Info Memoire Virtuelle au format txt
Sub Info_SWAP_Txt ()
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_PageFile",,48)
 
	MessageSwap = MessageSwap & Space(14) & "**************************************************" & vbCrLf
	MessageSwap = MessageSwap & Space(20) & "Fichier(s) d'échange (PageFile ou Swap):" & vbCrLf 
	MessageSwap = MessageSwap & Space(14) & "**************************************************" & vbCrLf & vbCrLf & vbCrLf
 
	For Each objItem in colItems
 
		SwapDrive = objItem.Drive
		SwapFileName = objItem.FileName & "." & objItem.Extension
		SwapPath = objItem.Name
		SwapFileSytem = objItem.FSName
		SwapInitialSize = objItem.InitialSize
		SwapMaxSize = objItem.MaximumSize
		SwapUseSize = objItem.FileSize
 
		' SÉLECTION DU TYPE D'UNITÉ À AFFICHÉ POUR A TAILLES UTILISEE
		SwapUseSize = UniteDD(SwapUseSize,2)
 
		MessageSwap = MessageSwap & FormatStrL("Lecteur",17,2) & " : " & FormatStrR(SwapDrive,10,2) & VBCRLF
		MessageSwap = MessageSwap & FormatStrL("Nom du fichier",17,2) & " : " & FormatStrR(SwapFileName,10,2) & VBCRLF
		MessageSwap = MessageSwap & FormatStrL("Chemin",17,2) & " : " & FormatStrR(SwapPath,10,2) & VBCRLF
		MessageSwap = MessageSwap & FormatStrL("File System",17,2) & " : " & FormatStrR(SwapFileSytem,10,2) & VBCRLF
		MessageSwap = MessageSwap & FormatStrL("Taille Initile",17,2) & " : " & FormatStrR(SwapInitialSize,10,2) & Space(4) & "Mo" & VBCRLF
		MessageSwap = MessageSwap & FormatStrL("Taille Maximum",17,2) & " : " & FormatStrR(SwapMaxSize,10,2) & Space(4) & "Mo" & VBCRLF
		MessageSwap = MessageSwap & FormatStrL("Taille Utilisée",17,2) & " : " & FormatStrR(SwapUseSize,10,2) & Space(4) & VBCRLF & VBCRLF
		MessageSwap = MessageSwap & "===========================================================================" & Space(14) & VBCRLF & VBCRLF
 
	Next
 
End Sub	
 
' Info Memoire Virtuelle au format html
Sub Info_SWAP_Html ()
 
	Set objWMIService = GetObject("winmgmts:\\" & ComputerName & "\root\cimv2")
	Set colItems = objWMIService.ExecQuery("Select * from Win32_PageFile",,48)
 
	For Each objItem in colItems
 
		DriveSwap(CountSwap) = objItem.Drive
		FileNameSwap(CountSwap) = objItem.FileName & "." & objItem.Extension
		PathSwap(CountSwap) = objItem.Name
		FileSytemSwap(CountSwap) = objItem.FSName
		InitialSizeSwap(CountSwap) = objItem.InitialSize
		MaxSizeSwap(CountSwap) = objItem.MaximumSize
		UseSizeSwap(CountSwap) = objItem.FileSize
 
		' SÉLECTION DU TYPE D'UNITÉ À AFFICHÉ POUR A TAILLES UTILISEE
		UseSizeSwap(CountSwap) = UniteDD(UseSizeSwap(CountSwap),1)
 
		CountSwap = CountSwap+1
		Redim Preserve DriveSwap(CountSwap)
		Redim Preserve FileNameSwap(CountSwap)
		Redim Preserve PathSwap(CountSwap)
		Redim Preserve FileSytemSwap(CountSwap)
		Redim Preserve InitialSizeSwap(CountSwap)
		Redim Preserve MaxSizeSwap(CountSwap)
		Redim Preserve UseSizeSwap(CountSwap)
 
	Next
 
End Sub	
 
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
 
'===============================================================================================
'		FONCTION DE MISE EN FORME POUR L'AFFICHAGE DU FICHIER DE SORTIE
'===============================================================================================	
 
'**********************************************************************
' Fonction de mise en forme du tableau : alignement des infos vers la gauche
' (ajout des espaces à la droite de la chaine de carractère)
'***********************************************************************
Function FormatStrL(ch,lmax,ExitFile)
l=len(ch)							' On calcule le nombre de carractère qui compose la chaine.
If l<lmax Then 						' Si ce nombre est inférieur à lmax (lmax correspond à la largeur max que l'on souhaite pour la colonne du tableau) alors 
	For k = l+1 To lmax				' On ajoute le nombre d'espace requis à la chaine de carractère pour avoir la bonne largeur à la cellule du tableau. 
		Select Case (ExitFile)
			case 1
				ch=ch & " "
			case 2
				ch=ch & " "
		End Select
	Next
End If
FormatStrL=ch						' On renvoie le résultat du traitement.
End Function
 
'**********************************************************************
' Fonction de mise en forme du tableau : alignement des infos vers la droite
' (ajout des espaces à la gauche de la chaine de carractère)
'**********************************************************************
 
Function FormatStrR(ch,lmax,ExitFile)
l=len(ch)							' On calcule le nombre de carractère qui compose la chaine.
If l<lmax Then 						' Si ce nombre est inférieur à lmax (lmax correspond à la largeur max que l'on souhaite pour la colonne du tableau) alors 
	For k = l+1 To lmax				' On ajoute le nombre d'espace requis à la chaine de carractère pour avoir la bonne largeur à la cellule du tableau.
		Select Case (ExitFile)
			case 1
				ch=" " & ch
			case 2
				ch=" " & ch
		End Select
	Next
End If
FormatStrR=ch						' On renvoie le résultat du traitement.
End Function
 
'**********************************************************************
' Fonction pour l'affichage html
' (met le caractère espace en code html :  si la varible est vide)
'**********************************************************************
Function FormatVideHtml(var)
	if (var <> "" OR var <> " ")then
		var = var
	else
		var = " "
	end if
 
	FormatVideHtml=var		' On renvoie le résultat du traitement.
 
end Function
 
'**********************************************************************
' Fonction de Calcule et de sélection de l'unité de taille des disques et partitions
' **********************************************************************
Function UniteDD(Size,TypeSortie)	
 
	Unite = ""
	Kilo=1024									' 1 Ko = 1024 octets
	Mega=1048576								' 1 Mo =  1 048 576 octets
	Giga=1073741824								' 1 Go = 1 073 741 824 octets
	Tera=1099511627776 							' 1Tera = 1099511627776 octets
	Peta=1125899906842624 						' 1 Peta = 1125899906842624 octets
	Exa=1152921504606846976						' 1 Exa = 1152921504606846976 octets
	Zetta=1180591620717411303424 				' 1 Zetta = 1180591620717411303424 octets
	Yotta=1208925819614629174706176 			' 1 Yotta = 1208925819614629174706176 octets
 
	SizeTxt = Size
 
	' Calcule de l'espace utilisé du disque en Ko / si Size > 0 et Size < Mega alors
	If ((Size > 0) AND (Size < 1048576)) Then
		Unite = "Ko"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Kilo,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Kilo,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1)
 
	' Calcule de l'espace utilisé du disque en Mo / si Size >= Mega et Size < Giga alors
	else if (Size >= 1048576) AND (Size < 1073741824) Then
		Unite = "Mo"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Mega,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html		
		Size =  FormatNumber(Size/Mega,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1)
 
	' Calcule de l'espace utilisé du disque en Go / si Size >= Giga et Size < Tera alors
	Else If (Size >= 1073741824) AND (Size < 1099511627776) Then
		Unite = "Go"		 
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Giga,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Giga,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1)
 
	' Calcule de l'espace utilisé du disque en To / si Tera >= 0 et Size < Peta alors
	else if (Size >= 1099511627776) AND (Size < 1125899906842624) Then
		Unite = "To"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Tera,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Tera,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1) 		
 
	' Calcule de l'espace utilisé du disque en Po / si Size >= Peta et Size < Exa alors
	Else If (Size >= 1125899906842624) AND (Size < 1152921504606846976) Then
		Unite = "Po"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Peta,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Peta,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1) 
 
	' Calcule de l'espace utilisé du disque en Eo / si Size >= Exa et Size < Zetta alors
	else if (Size >= 1152921504606846976) AND (Size < 1180591620717411303424) Then
		Unite = "Eo"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Exa,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Exa,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1) 		
 
	' Calcule de l'espace utilisé du disque en Zo / si Size >= Zetta et Size < Yotta alors
	Else If (Size >= 1180591620717411303424) AND (Size < 1208925819614629174706176) Then
		Unite = "Zo"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Zetta,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Zetta,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1) 
 
	' Calcule de l'espace utilisé du disque en Yo / si Size >= Yotta  alors
	else if Size >= 1208925819614629174706176 Then
		Unite = "Yo"
		' Pour affichage txt
		SizeTxt = FormatNumber(SizeTxt/Yotta,2)
		SizeTxt = Fix(SizeTxt)
		SizeTxt = FormatStrR(SizeTxt,7,2) & FormatStrR(Unite,3,2) 
		' Pour affichage html
		Size =  FormatNumber(Size/Yotta,2)
	'	Size =  Fix(Size)	' Fix permet de tronquer la partie décimale 
		Size =  FormatStrR(Size,7,1) & FormatStrR(Unite,5,1) 
 
	End if
	end if
	End If
	end if
	End If
	end if
	End If
	end if
 
	Select Case(TypeSortie)
		Case(1)
			UniteDD = Size
		Case(2)
			UniteDD = SizeTxt
	End Select
 
End Function
 
 
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
 
'============================================================
'		ENCHAINEMENT DES INSTRUCTIONS
'============================================================
On Error Resume Next
 
' ******************************
' Récupération du ComputerName 
' ******************************
Set WSHShell = WScript.CreateObject("WScript.Network")
ComputerName = WSHShell.ComputerName 
 
' ******************************************************
' Récupération des Informations par appel de procédures  
' ******************************************************
Info_OS							' Récupération des informations sur le Système d'Exploitation
Info_RAM_Txt					' Récupération des informations sur la RAM au format Txt
Info_RAM_Html					' Récupération des informations sur la RAM au format Html
Info_SWAP_Txt					' Récupération des informations BIOS au format Txt
Info_SWAP_Html					' Récupération des informations BIOS au format Html
 
 
'*****************************************
'	Génération du fichier de sortie TXT		
'*****************************************
Set fso = CreateObject("Scripting.FileSystemObject")
 
'---- Détermine si le fichier texte existe déjà ou s'il doit le créer ----
If Not fso.FileExists(".\Rapports\txt\Invt_" & ComputerName & "_Memoire" & ".txt") Then
        set ts = fso.CreateTextFile(".\Rapports\txt\Invt_" & ComputerName & "_Memoire" & ".txt", True)
Else
        set ts = fso.OpenTextFile(".\Rapports\txt\Invt_" & ComputerName & "_Memoire" & ".txt", 2, True)
End If
 
 
' On ecrit dans le fichier txt
ts.write MessageOS
ts.write MessageRAM
ts.write MessageSwap
 
 
'======================================================================================================================
'******************************************
'	Génération du fichier de sortie HTML		
'******************************************
Set fso = CreateObject("Scripting.FileSystemObject")
 
'---- Détermine si le fichier texte existe déjà ou s'il doit le créer ----
If Not fso.FileExists(".\Rapports\html\Invt_" & ComputerName & "_Memoire" & ".html") Then
        set ts = fso.CreateTextFile(".\Rapports\html\Invt_" & ComputerName & "_Memoire" & ".html", True)
Else
        set ts = fso.OpenTextFile(".\Rapports\html\Invt_" & ComputerName & "_Memoire" & ".html", 2, True)
End If
 
 
' On ecrit dans le fichier html
ts.writeline "<HTML>"
ts.writeline "<HEAD>"
ts.writeline "<!--<META NAME='GENERATOR' CONTENT='Inventaire Machine par G.FERNANDEZ'>-->"
ts.writeline "</HEAD>"
ts.writeline "<STYLE>"
ts.writeline "A { text-decoration: none }"
ts.writeline "A:hover { text-decoration: underline }"
ts.writeline "TD { font: 80% verdana, arial; color: #000000; vertical-align: text-center; text-align: left }"
ts.writeline "TD.cr { font: 80% verdana, arial; color: #000000; vertical-align: text-center; text-align: right }"
ts.writeline "TD.cc { font: 80% verdana, arial; color: #000000; vertical-align: text-center; text-align: center }"
ts.writeline "TD.pt { font: bold 140% verdana, arial; color: #000080; vertical-align: text-center }"
ts.writeline "TD.dt { font: bold 110% verdana, arial; color: #000080; vertical-align: text-center }"
ts.writeline "td.GBTxt { font: bold verdana; color: Blue}"
ts.writeline "td.BTxt { font: verdana; color: Blue}"
ts.writeline "td.GRTxt { font: bold verdana; color: Red}"
ts.writeline "td.RTxt { font: verdana; color: Red}"
ts.writeline "td.tpTxt { font-size: 9px; font-weight:bold}"
ts.writeline "a:link {color:red; text-decoration: underline;}"
ts.writeline "a:visited {color:red; text-decoration: underline;}"
ts.writeline "a:hover {color:red; text-decoration: none;}"
ts.writeline ".zonetext { background-color:#FDFFB9; font-size: 12px; font-family: verdana; overflow:auto; }"
ts.writeline "</STYLE>"
ts.writeline "<SCRIPT language='JavaScript'>"
ts.writeline "//====================================================================="
ts.writeline "// Ces fonctions permettent la séléction d'une ligne sur un tableau ."
ts.writeline "//====================================================================="
ts.writeline "var select = 0; var temp;"
ts.writeline "// colore la ligne en transparent"
ts.writeline "function transparent(ligne)"
ts.writeline "{       if (ligne!=temp && ligne.style.background!='#FDFFB9') ligne.style.background='#FDFFB9'; }"
ts.writeline "// colore la ligne en vert"
ts.writeline "function green(ligne)"
ts.writeline "{       if (ligne!=temp && ligne.style.background!='#00FF99') ligne.style.background='#00FF99'; }"
ts.writeline "// colore la ligne en transparent si elle est verte"
ts.writeline "// remet en transparent la ligne selectionnée precedement et colore celle si en vert si differente"
ts.writeline "// indique qu'une ligne est selectionnée en mettant le parametre select a 1"
ts.writeline "function selec(ligne)"
ts.writeline "{       if (!select)    {       select = 1; ligne.style.background='lavender'; temp = ligne;    }"
ts.writeline "	else	{       if (ligne.style.background=='lavender'){ select = 0; ligne.style.background='#FDFFB9'; temp = ligne;}"
ts.writeline "				else{       temp.style.background='#FDFFB9'; ligne.style.background='lavender'; temp=ligne;} } }"
ts.writeline "</SCRIPT>"
ts.writeline "<TITLE>Inventaire Mémoire<" & ComputerName &  " - par GFE></TITLE>"
ts.writeline "<BODY BGCOLOR=""#FDFFB9"">"
ts.writeline "<TABLE WIDTH=100% border=0>"
ts.writeline "<tr><table  border=0><tr><td CLASS=dt><A NAME=""haut"">Inventaire Machine :</td>"
ts.writeline "<td CLASS=dt>" & ComputerName & " du " & datetime & "</td></tr>"
ts.writeline "<tr><td CLASS=pt><br></td></tr>"
ts.writeline "<tr><table  border=0>"
ts.writeline "<tr><td CLASS=RTxt><A HREF=""#1"">Mémoire Vive (RAM)</A></td><td>   </td><td CLASS=RTxt><A HREF=""#2"">Mémoire Virtuelle (Page File ou Swap)</A></td></tr>"
ts.writeline "<tr><td CLASS=pt><br></td></tr>"
ts.writeline "</table>"
ts.writeline "<tr><table WIDTH=100% border=0><tr><td CLASS=pt COLSPAN=2>Mémoire</td></tr></table>"
ts.writeline "</tr><tr><hr></tr>"
ts.writeline "</TABLE>"
'===============================================================================================================================================================
' 										TABLEAU D'INFORMATION SUR LES APPLICATIONS INSTALLEES (DYNAMIQUE)
'===============================================================================================================================================================
ts.writeline "<br><br><br>"
ts.writeline "<TABLE WIDTH=100% border=0>"
ts.writeline "<tr><table  border=0><td CLASS=dt><A NAME=""1"">Mémoire Vive (RAM) :</td></table>"
ts.writeline "</tr><tr><hr></tr>"
ts.writeline "</TABLE>"
ts.writeline "<TABLE border=0><tr><td width=16> </td><td width=16></td><td width=16></td><td width=16></td><td width=16></td><td></td></tr>"
for i = 0 to CountRam-1	' On fait -1 à CountRam car le dernier de la fonction des infos RAM incémente le compteur à chaque fin d'inventaire RAM
ts.writeline "<tr><td></td><td></td><td></td><td>Barrette <b>" & DeviceRAM(i) &"</b>  </td><td>  :  </td><td><p align='right'>" & capaRAM(i) & "</p></td><td> Mo  "& LabelRAM(i) & "</td</tr>"
next
ts.writeline "<tr><td></td><td></td><td></td><td>Total  </td><td>  :  </td><td class=GRTxt><p align='right'>" & totalRAM & "</p></td><td> Mo</td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td></td><td><br></td><td>  </td><td></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>RAM visible  </td><td>  :  </td><td class=GBTxt><p align='right'>" & VisibleRAM & "</p></td><td> Mo</td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>RAM masquée  </td><td>  :  </td><td class=GRTxt><p align='right'>" & MasqueRAM & "</p></td><td> Mo</td></tr>"
ts.writeline "<tr><td> </td></tr>"
ts.writeline "</TABLE>"
ts.writeline "<table border=0><tr><td width=16> </td><td width=25% class=tpTxt><A HREF=""#haut"">(haut)</A></td><td></td></tr><table>"	
 
ts.writeline "<br><br><br>"
ts.writeline "<TABLE WIDTH=100% border=0>"
ts.writeline "<tr><table  border=0><td CLASS=dt><A NAME=""2"">Mémoire Virtuelle (Page File ou Swap) :</td></table>"
ts.writeline "</tr><tr><hr></tr>"
ts.writeline "<TABLE border=0><tr><td width=16> </td><td width=16></td><td width=16></td><td width=16></td><td width=16></td></tr>"
for i = 0 to CountSwap-1	' On fait -1 à CountSwap car le dernier de la fonction des infos SWAP incémente le compteur à chaque fin d'inventaire SWAP
ts.writeline "<tr><td></td><td></td><td></td><td>Lecteur  </td><td>  :  </td><td><p align='right'>" & DriveSwap(i) & "</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>Nom du fichier  </td><td>  :  </td><td><p align='right'>" & FileNameSwap(i) & "</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>Emplacement  </td><td>  :  </td><td class=GBTxt><p align='right'>" & PathSwap(i) & "</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>File Syteme  </td><td>  :  </td><td><p align='right'>" & FileSytemSwap(i) & "</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>Taille Initial  </td><td>  :  </td><td><p align='right'>" & InitialSizeSwap(i) & " Mo</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>Taille Maximum  </td><td>  :  </td><td><p align='right'>" & MaxSizeSwap(i) & " Mo</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td>Espace Utilisé  </td><td>  :  </td><td class=GRTxt><p align='right'>" & UseSizeSwap(i) & "</p></td></tr>"
ts.writeline "<tr><td></td><td></td><td></td><td><br><br><br></td><td><br><br><br<td>  </td></td><td></td></tr>"
next
ts.writeline "</TABLE>"
ts.writeline "<table border=0><tr><td width=16> </td><td width=25% class=tpTxt><A HREF=""#haut"">(haut)</A></td><td></td></tr><table>"	
 
'===============================================================================================================================================================
' Affichage du message de fin d'inventaire.
'Msgbox "Inventaire Terminé" & Space(10), vbInformation, "Inventaire"
 
' Affichage du message du fichier de sortie, résultat de l'inventaire.
'Set WSHShell = CreateObject("WScript.Shell")
'WSHShell.run (ComputerName & "_Inventaire" & ".txt")
Wscript.quit 'On quite le script | 
Partager