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
| ' Les éléments à démarrage automatique + ListProcessCmdLine.vbs © Hackoo © 2011
' Mise à jour le 17/09/2015 : Ajout de la taille des processus
Set fso = CreateObject("Scripting.FileSystemObject")
Set Ws = CreateObject("WScript.Shell")
Set ProcessEnv = Ws.Environment("Process")
NomMachine = ProcessEnv("COMPUTERNAME")
NomUtilisateur = ProcessEnv("USERNAME")
NomFichierLog="Liste_Processus.txt"
temp = Ws.ExpandEnvironmentStrings("%temp%")
PathNomFichierLog = temp & "\" & NomFichierLog
Set OutPut = fso.OpenTextFile(temp & "\" & NomFichierLog,2)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process")
count=0
Call Infosys()
OutPut.WriteLine "[COLOR=""Red""]" & String(14,"*")& "Liste des Processus en cours d'exécution le " & date & " à " & time & " sur Le PC "& NomMachine &" connecté en tant que " & NomUtilisateur & String(14,"*")& vbNewline & String(80,"*") & "[/COLOR]"
For Each objProcess in colProcesses
ProcessName = objProcess.Name
ProcessID = objProcess.ProcessID
CommandLine = objProcess.CommandLine
Process_Size = ConvertSize(objProcess.WorkingSetSize)
count=count+1
Texte = "Numéro PID = "& ProcessID & VbNewLine & "Nom du Processus = " & ProcessName & VbNewLine &"Ligne de Commande = "& CommandLine &_
VbNewLine & "Taille = "& Process_Size & VbNewLine & String(100,"*")
OutPut.WriteLine Texte
Next
OutPut.WriteLine "Il y a "& Count &" Processus en cours d'exécution le " & date & " à " & time & " sur Le PC "& NomMachine &" connecté en tant que " & NomUtilisateur & vbNewline
Call StartupCommand()
Call Explorer(PathNomFichierLog)
'*************************************************************************************************************************************************
Function StartupCommand()
strComputer = "."
resultat=""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colStartupCommands = objWMIService.ExecQuery ("Select * from Win32_StartupCommand")
For Each objStartupCommand in colStartupCommands
resultat=resultat & "Nom: " & objStartupCommand.Name & vbNewline
resultat=resultat & "Description: " & objStartupCommand.Description & vbNewline
resultat=resultat & "Emplacement: " & objStartupCommand.Location & vbNewline
resultat=resultat & "Commande: " & objStartupCommand.Command & vbNewline
resultat=resultat & "Utilisateur: " & objStartupCommand.User & vbNewline
resultat=resultat & String(100,"*") & vbNewline
Next
OutPut.WriteLine "[COLOR=""Red""]" & String(50,"*") &" Les éléments à démarrage automatique "& String(40,"*") &"[/COLOR]"
OutPut.WriteLine resultat & "[/quote]"
End Function
'*************************************************************************************************************************************************
Function Explorer(File)
Set ws=CreateObject("wscript.shell")
ws.run "Notepad "& File,1,False
End Function
'*************************************************************************************************************************************************
Function InfoSys()
strComputer = "."
strMessage=""
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
Set colSettings2 = objWMIService.ExecQuery ("Select * from Win32_BIOS")
Set colSettings3 = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
For Each objBIOS in colSettings2
strMessage=strMessage & "[quote]BIOS " & objBIOS.Version & vbNewline & vbNewline
Next
For Each objComputer in colSettings
strMessage=strMessage & "Nom de l'ordinateur : " & objComputer.Name & vbNewline & "Fabriquant: " & objComputer.Manufacturer & vbNewline & "Modèle : " & objComputer.Model & vbNewline & vbNewline
Next
For Each objOperatingSystem in colSettings3
strMessage=strMessage & objOperatingSystem.Name & vbNewline
strMessage=strMessage & "Version " & objOperatingSystem.Version & vbNewline
strMessage=strMessage & "Service Pack " & objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion &vbNewline
strMessage=strMessage & "Dossier de Windows: " & objOperatingSystem.WindowsDirectory &vbNewline
Next
OutPut.WriteLine strMessage & ""
end Function
'****************************************************************************************************************************************************
Function ConvertSize(Size)
Dim CommaLocate
Do While InStr(Size,",") 'Remove commas from size
CommaLocate = InStr(Size,",")
Size = Mid(Size,1,CommaLocate - 1) & _
Mid(Size,CommaLocate + 1,Len(Size) - CommaLocate)
Loop
Dim Suffix:Suffix = " Bytes"
If Size >= 1024 Then suffix = " KB"
If Size >= 1048576 Then suffix = " MB"
If Size >= 1073741824 Then suffix = " GB"
If Size >= 1099511627776 Then suffix = " TB"
Select Case Suffix
Case " KB" Size = Round(Size / 1024, 1)
Case " MB" Size = Round(Size / 1048576, 1)
Case " GB" Size = Round(Size / 1073741824, 1)
Case " TB" Size = Round(Size / 1099511627776, 1)
End Select
ConvertSize = Size & Suffix
End Function
'******************************************************************************************************************************************************* |
Partager