' ---------------------------------------------------------- ' Script d'affichage des chemins complets des processus ' en cours sur une machine sous Windows NT/W2K/XP ' avec affichage de la description et version ' Syntaxe: ' processpath [] ' Paramètre : ' : nom NetBIOS de l'ordinateur (local ou distant) ' si ce nom est omis, ordinateur local ' ' JC BELLAMY © 2003 ' ---------------------------------------------------------- Const SW_SHOWNORMAL=1 Dim net, args, shell, System, tools Set net = Wscript.CreateObject("WScript.Network") Set args = Wscript.Arguments set shell = Wscript.CreateObject("WScript.Shell") Set fso = WScript.CreateObject("Scripting.FileSystemObject") if args.count>0 then Computer=args(0) else Computer=net.ComputerName end if TestHost true wscript.echo "Processus en cours sur " & ucase(Computer) & " : " & VBCRLF jcbCOM="jcb.tools" TestCOMExists jcbCOM,"jcb.ocx" set tools =Wscript.CreateObject(jcbCOM,"event_") Set System=GetObject("winmgmts:{impersonationLevel=impersonate}!//" & Computer).InstancesOf("Win32_Process") mess="" for each Process in System If not IsNull(Process.ExecutablePath) Then filename=Replace("\\" & Computer & "\" & CStr(Process.ExecutablePath), ":","$") set objexe = tools.GetVersion(filename) mess=mess & FormatStrR(Process.Handle,5) & " " & Process.Name & VBCRLF mess=mess & " " & Process.ExecutablePath & VBCRLF if objexe.isVer then mess=mess & AddInfo("",objexe.FileDescription) mess=mess & AddInfo("Version ",objexe.FileVersion) mess=mess & AddInfo("",objexe.LegalCopyright) end if mess=mess & VBCRLF End If next ' wscript.echo mess Wscript.quit '-------------------------------------------------------------------- Sub TestCOMExists(name,module) ' Vérification d'installation d'un objet COM dummy = shell.RegRead("HKCR\" & name & "\") if err.number<>0 then ' contrôle ActiveX non enregistré pathmodule=getpath()& module If not fso.fileExists(pathmodule) Then Mess = "Le contrôle ActiveX " & name & " est requis." & VBCRLF Mess=Mess & "Il est contenu dans le fichier " & module & VBCRLF Mess=Mess & "Or ce fichier n'a pas été trouvé." & VBCRLF MsgBox Mess, vbExclamation wscript.quit End If err.clear shell.Run "regsvr32.exe " & quote & pathmodule & quote, SW_SHOWNORMAL,true dummy = shell.RegRead("HKCR\" & name & "\") if err.number<>0 then Mess = "Le contrôle ActiveX " & name & " n'a pas pu être enregistré" MsgBox Mess, vbExclamation wscript.quit end if end if End Sub '-------------------------------------------------------------------- Function FormatStrR(ch,lmax) l=len(ch) If l"cscript" then If force then Init="Ce script doit être lancé avec CSCRIPT" Else Init="Il est préférable de lancer ce script avec CSCRIPT" End If rep=MsgBox(Init & VBCRLF & _ "Cela peut être rendu permanent avec la commande" & VBCRLF & _ "cscript //H:CScript //S /Nologo" & VBCRLF & _ "Voulez-vous que ce soit fait automatiquement?", _ vbYesNo + vbQuestion,strappli) if rep=vbYes then nomcmd="setscript.bat" Set ficcmd = fso.CreateTextFile(nomcmd) ficcmd.writeline "@echo off" ficcmd.writeline "cscript //H:CScript //S /Nologo" ficcmd.writeline "pause" params="" For i = 0 To nbargs-1 params=params & " " & args(i) next ficcmd.writeline chr(34) & strappli & chr(34) & params ficcmd.writeline "pause" ficcmd.close shell.Run nomcmd, SW_SHOWNORMAL,true force=true end if If force then WScript.Quit end if end sub '-------------------------------------------------------------------- Function AddInfo(prompt,s) If s<>"" Then AddInfo=" " & prompt & s & VBCRLF else AddInfo="" End Function '--------------------------------------------------------------------