hackoo

ListProcessCmdLine.vbs

Jan 25th, 2012
1,137
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Les éléments à démarrage automatique + ListProcessCmdLine.vbs © Hackoo © 2011
  2. Set fso = CreateObject("Scripting.FileSystemObject")
  3. Set Ws = CreateObject("WScript.Shell")
  4. Set ProcessEnv = Ws.Environment("Process")
  5. NomMachine = ProcessEnv("COMPUTERNAME")
  6. NomUtilisateur = ProcessEnv("USERNAME")
  7. NomFichierLog="Liste_Processus.txt"
  8. temp = Ws.ExpandEnvironmentStrings("%temp%")
  9. PathNomFichierLog = temp & "\" & NomFichierLog
  10. Set OutPut = fso.CreateTextFile(temp & "\" & NomFichierLog,2)
  11. strComputer = "."
  12. Set objWMIService = GetObject("winmgmts:" _
  13. & "{impersonationLevel=impersonate}!\\" _
  14. & strComputer & "\root\cimv2")
  15. Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process")
  16. count=0
  17. Call Infosys
  18. OutPut.WriteLine "[B][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][/B]"
  19. For Each objProcess in colProcesses
  20. ProcessName = objProcess.Name
  21. ProcessID = objProcess.ProcessID
  22. CommandLine = objProcess.CommandLine   
  23. count=count+1
  24. Texte = "Numéro PID = "& objProcess.ProcessID & VbNewLine & "Nom du Processus = " & objProcess.Name & VbNewLine &"Ligne de Commande = "& objProcess.CommandLine &_
  25. VbNewLine & String(100,"*")
  26. OutPut.WriteLine Texte
  27. Next
  28.  
  29. 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
  30. Call StartupCommand
  31. 'OutPut.WriteLine FormatNumber(Timer - StartTime, 0) & " seconds."
  32. Function StartupCommand()
  33. strComputer = "."
  34. resultat=""
  35. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
  36. Set colStartupCommands = objWMIService.ExecQuery ("Select * from Win32_StartupCommand")
  37.  
  38. For Each objStartupCommand in colStartupCommands
  39. resultat=resultat & "Nom: " & objStartupCommand.Name & vbNewline
  40. resultat=resultat & "Description: " & objStartupCommand.Description & vbNewline
  41. resultat=resultat & "Emplacement: " & objStartupCommand.Location & vbNewline
  42. resultat=resultat & "Commande: " & objStartupCommand.Command & vbNewline
  43. resultat=resultat & "Utilisateur: " & objStartupCommand.User & vbNewline
  44. resultat=resultat & String(100,"*") & vbNewline
  45. Next
  46. OutPut.WriteLine "[B][COLOR=""Red""]" & String(50,"*") &" Les éléments à démarrage automatique "& String(40,"*") &"[/COLOR][/B]"
  47. OutPut.WriteLine resultat & "[/quote]"
  48. end Function
  49.  
  50. Explorer(PathNomFichierLog)
  51.  
  52. Function Explorer(File)
  53.     Set ws=CreateObject("wscript.shell")
  54.     ws.run "Notepad "& File,1,True
  55. end Function
  56.  
  57. Function InfoSys
  58. strComputer = "."
  59. strMessage=""
  60. Set objWMIService = GetObject("winmgmts:"  & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  61. Set colSettings = objWMIService.ExecQuery  ("Select * from Win32_ComputerSystem")
  62. Set colSettings2 = objWMIService.ExecQuery ("Select * from Win32_BIOS")
  63. Set colSettings3 = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
  64. For Each objBIOS in colSettings2
  65.       strMessage=strMessage & "[quote][B]BIOS " & objBIOS.Version & vbNewline & vbNewline
  66. Next
  67. For Each objComputer in colSettings
  68.       strMessage=strMessage & "Nom de l'ordinateur : " & objComputer.Name & vbNewline & "Fabriquant: " & objComputer.Manufacturer & vbNewline & "Modèle : " & objComputer.Model & vbNewline & vbNewline
  69.  
  70. Next
  71. For Each objOperatingSystem in colSettings3
  72.       strMessage=strMessage &  objOperatingSystem.Name & vbNewline
  73.       strMessage=strMessage &  "Version " & objOperatingSystem.Version & vbNewline
  74.       strMessage=strMessage &  "Service Pack " & objOperatingSystem.ServicePackMajorVersion & "." & objOperatingSystem.ServicePackMinorVersion &vbNewline
  75.       strMessage=strMessage &  "Dossier de Windows: " & objOperatingSystem.WindowsDirectory &vbNewline
  76. Next
  77. OutPut.WriteLine strMessage & "[/B]"
  78. end Function
RAW Paste Data