begin process at 2012 02 17 01:51:04
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

VBScript

 > MES TEST ET MES RECHERCHES SUR WMI, PROCESSUS ET INTERNET

MES TEST ET MES RECHERCHES SUR WMI, PROCESSUS ET INTERNET


 Information sur la source

 Description

Il était une fois ou j'ai du faire des recherches sur l'utilisation des objets wmi et manipulation d'internet, concretement ça ne servira pas directement tel quel mais ç'est peut être pratique pour ceux qui pourrons recupérer les bouts de codes qui pourons leur être util. pas de zip, c'est à copier dans un .txt et renommer .vbs ou autre pg vb

Source

  • public sub quickList(arg,suffix)
  • dim obj
  • dim fw
  • dim fname
  • dim fserv
  • dim fsw
  • fname = GetTempFile("listingChampProcessIexp.txt")
  • fserv = GetTempFile("listingSercices.txt")
  • Set obj = WScript.CreateObject("Scripting.FileSystemObject")
  • '*******************************************************************************
  • if obj.fileExists(fname) then
  • fname = GetTempFile("listingChampProcessIexp" & suffix & ".txt")
  • end if
  • '*******************************************************************************
  • set fw = obj.createTextFile(fname,true)
  • set fsw = obj.createTextFile(fserv,true)
  • Set objWMI = GetObject("winmgmts:root\cimv2")
  • '*******************************************************************************
  • reqVbs = "Select * from Win32_process"
  • For Each oproc In objWMI.execquery(reqVbs)
  • if oproc.Name="iexplore.exe" then
  • fw.writeline "Caption; " & oproc.Caption
  • fw.writeline "CommandLine; " & oproc.CommandLine
  • fw.writeline "CreationClassName; " & oproc.CreationClassName
  • fw.writeline "CreationDate; " & oproc.CreationDate
  • fw.writeline "CSCreationClassName; " & oproc.CSCreationClassName
  • fw.writeline "CSName; " & oproc.CSName
  • fw.writeline "Description; " & oproc.Description
  • fw.writeline "ExecutablePath; " & oproc.ExecutablePath
  • fw.writeline "ExecutionState; " & oproc.ExecutionState
  • fw.writeline "Handle; " & oproc.Handle
  • fw.writeline "HandleCount; " & oproc.HandleCount
  • fw.writeline "InstallDate; " & oproc.InstallDate
  • fw.writeline "KernelModeTime; " & oproc.KernelModeTime
  • fw.writeline "MaximumWorkingSetSize; " & oproc.MaximumWorkingSetSize
  • fw.writeline "MinimumWorkingSetSize; " & oproc.MinimumWorkingSetSize
  • fw.writeline "Name; " & oproc.Name
  • fw.writeline "OSCreationClassName; " & oproc.OSCreationClassName
  • fw.writeline "OSName; " & oproc.OSName
  • fw.writeline "OtherOperationCount; " & oproc.OtherOperationCount
  • fw.writeline "OtherTransferCount; " & oproc.OtherTransferCount
  • fw.writeline "PageFaults; " & oproc.PageFaults
  • fw.writeline "PageFileUsage; " & oproc.PageFileUsage
  • fw.writeline "ParentProcessId; " & oproc.ParentProcessId
  • fw.writeline "PeakPageFileUsage; " & oproc.PeakPageFileUsage
  • fw.writeline "PeakVirtualSize; " & oproc.PeakVirtualSize
  • fw.writeline "PeakWorkingSetSize; " & oproc.PeakWorkingSetSize
  • fw.writeline "Priority; " & oproc.Priority
  • fw.writeline "PrivatePageCount; " & oproc.PrivatePageCount
  • fw.writeline "ProcessId; " & oproc.ProcessId
  • fw.writeline "QuotaNonPagedPoolUsage; " & oproc.QuotaNonPagedPoolUsage
  • fw.writeline "QuotaPagedPoolUsage; " & oproc.QuotaPagedPoolUsage
  • fw.writeline "QuotaPeakNonPagedPoolUsage; " & oproc.QuotaPeakNonPagedPoolUsage
  • fw.writeline "QuotaPeakPagedPoolUsage; " & oproc.QuotaPeakPagedPoolUsage
  • fw.writeline "ReadOperationCount; " & oproc.ReadOperationCount
  • fw.writeline "ReadTransferCount; " & oproc.ReadTransferCount
  • fw.writeline "SessionId; " & oproc.SessionId
  • fw.writeline "Status; " & oproc.Status
  • fw.writeline "TerminationDate; " & oproc.TerminationDate
  • fw.writeline "ThreadCount; " & oproc.ThreadCount
  • fw.writeline "UserModeTime; " & oproc.UserModeTime
  • fw.writeline "VirtualSize; " & oproc.VirtualSize
  • fw.writeline "WindowsVersion; " & oproc.WindowsVersion
  • fw.writeline "WorkingSetSize; " & oproc.WorkingSetSize
  • fw.writeline "WriteOperationCount; " & oproc.WriteOperationCount
  • fw.writeline "WriteTransferCount; " & oproc.WriteTransferCount
  • end if ' FIN DE oproc.Name="iexplore.exe"
  • Next
  • call jexecute(fname)
  • '*******************************************************************************
  • '*******************************************************************************
  • if arg then
  • reqVbs = "select * from win32_service"
  • For Each oproc In objWMI.execquery(reqVbs)
  • 'Wscript.echo oproc.Name & " = " & oproc.State
  • fsw.writeline oproc.Name & " = " & oproc.State
  • Next
  • call jexecute(fserv)
  • end if
  • fw.close
  • fsw.close
  • Set objWMI = Nothing
  • set obj = nothing
  • end sub
  • '*******************************************************************************
  • '*******************************************************************************
  • '*******************************************************************************
  • public sub pro()
  • '*******************************************************************************
  • dim obj
  • dim fw
  • dim fname
  • dim fserv
  • dim fsw
  • fname = GetTempFile("listingChampProcessIexp.txt")
  • fserv = GetTempFile("listingSercices.txt")
  • Set obj = WScript.CreateObject("Scripting.FileSystemObject")
  • set fw = obj.createTextFile(fname,true)
  • set fsw = obj.createTextFile(fserv,true)
  • Set objWMI = GetObject("winmgmts:root\cimv2")
  • '*******************************************************************************
  • if msgbox("liste process",vbyesNo,"liste process") = vbYes then
  • reqVbs = "Select * from Win32_process"
  • For Each oproc In objWMI.execquery(reqVbs)
  • if oproc.Name="iexplore.exe" then
  • fw.writeline "Caption; " & oproc.Caption
  • fw.writeline "CommandLine; " & oproc.CommandLine
  • fw.writeline "CreationClassName; " & oproc.CreationClassName
  • fw.writeline "CreationDate; " & oproc.CreationDate
  • fw.writeline "CSCreationClassName; " & oproc.CSCreationClassName
  • fw.writeline "CSName; " & oproc.CSName
  • fw.writeline "Description; " & oproc.Description
  • fw.writeline "ExecutablePath; " & oproc.ExecutablePath
  • fw.writeline "ExecutionState; " & oproc.ExecutionState
  • fw.writeline "Handle; " & oproc.Handle
  • fw.writeline "HandleCount; " & oproc.HandleCount
  • fw.writeline "InstallDate; " & oproc.InstallDate
  • fw.writeline "KernelModeTime; " & oproc.KernelModeTime
  • fw.writeline "MaximumWorkingSetSize; " & oproc.MaximumWorkingSetSize
  • fw.writeline "MinimumWorkingSetSize; " & oproc.MinimumWorkingSetSize
  • fw.writeline "Name; " & oproc.Name
  • fw.writeline "OSCreationClassName; " & oproc.OSCreationClassName
  • fw.writeline "OSName; " & oproc.OSName
  • fw.writeline "OtherOperationCount; " & oproc.OtherOperationCount
  • fw.writeline "OtherTransferCount; " & oproc.OtherTransferCount
  • fw.writeline "PageFaults; " & oproc.PageFaults
  • fw.writeline "PageFileUsage; " & oproc.PageFileUsage
  • fw.writeline "ParentProcessId; " & oproc.ParentProcessId
  • fw.writeline "PeakPageFileUsage; " & oproc.PeakPageFileUsage
  • fw.writeline "PeakVirtualSize; " & oproc.PeakVirtualSize
  • fw.writeline "PeakWorkingSetSize; " & oproc.PeakWorkingSetSize
  • fw.writeline "Priority; " & oproc.Priority
  • fw.writeline "PrivatePageCount; " & oproc.PrivatePageCount
  • fw.writeline "ProcessId; " & oproc.ProcessId
  • fw.writeline "QuotaNonPagedPoolUsage; " & oproc.QuotaNonPagedPoolUsage
  • fw.writeline "QuotaPagedPoolUsage; " & oproc.QuotaPagedPoolUsage
  • fw.writeline "QuotaPeakNonPagedPoolUsage; " & oproc.QuotaPeakNonPagedPoolUsage
  • fw.writeline "QuotaPeakPagedPoolUsage; " & oproc.QuotaPeakPagedPoolUsage
  • fw.writeline "ReadOperationCount; " & oproc.ReadOperationCount
  • fw.writeline "ReadTransferCount; " & oproc.ReadTransferCount
  • fw.writeline "SessionId; " & oproc.SessionId
  • fw.writeline "Status; " & oproc.Status
  • fw.writeline "TerminationDate; " & oproc.TerminationDate
  • fw.writeline "ThreadCount; " & oproc.ThreadCount
  • fw.writeline "UserModeTime; " & oproc.UserModeTime
  • fw.writeline "VirtualSize; " & oproc.VirtualSize
  • fw.writeline "WindowsVersion; " & oproc.WindowsVersion
  • fw.writeline "WorkingSetSize; " & oproc.WorkingSetSize
  • fw.writeline "WriteOperationCount; " & oproc.WriteOperationCount
  • fw.writeline "WriteTransferCount; " & oproc.WriteTransferCount
  • end if ' FIN DE oproc.Name="iexplore.exe"
  • Next
  • call jexecute(fname)
  • '*******************************************************************************
  • end if ' FIN DE if msgbox("liste process",vbyesNo,"liste process") = vbYes
  • '*******************************************************************************
  • if msgbox("liste sercices",vbyesNo,"liste services") = vbYes then
  • reqVbs = "select * from win32_service"
  • For Each oproc In objWMI.execquery(reqVbs)
  • 'Wscript.echo oproc.Name & " = " & oproc.State
  • fsw.writeline oproc.Name & " = " & oproc.State
  • Next
  • call jexecute(fserv)
  • end if
  • '*******************************************************************************
  • if msgbox("afficher nom processeur",vbyesNo,"truc acec processor") = vbYes then
  • reqVbs = "select * from win32_Processor"
  • For Each oproc In objWMI.execquery(reqVbs)
  • 'if oproc.Name="iexplorer.exe" then
  • Wscript.echo oproc.Name & " = " & oproc.ProcessorId
  • 'end if
  • Next
  • end if
  • '*******************************************************************************
  • fw.close
  • fsw.close
  • Set objWMI = Nothing
  • set obj = nothing
  • end sub
  • '*******************************************************************************
  • '*******************************************************************************
  • '*****************METHODE MAIN LA PRINCIPALE QUOI!!!***********************
  • '*******************************************************************************
  • '*******************************************************************************
  • '*******************************************************************************
  • Dim WshShell,obj
  • Set WshShell=WScript.CreateObject("WScript.Shell")
  • if msgbox ("test sur les processus?",vbyesNo,"test processus?") = vbYes then
  • call pro
  • end if
  • if msgbox ("autre test sur les nom de processus?",vbYesNo,"autre test?") = vbYes then
  • call autreTest
  • end if
  • dim testnet
  • Dim IE
  • Set IE = CreateObject("InternetExplorer.Application")
  • testnet = msgbox ("test chrono conexion internet?",vbyesNo,"test net?")
  • Dim a
  • a = inputbox("url A tester","url a tester")
  • if a = "" then a = "http://www.google.fr/"
  • '*****je voulais voir les differances de processus*******************************
  • call quickList(false,"")
  • '************************************************************************************
  • With IE
  • .Left = 200
  • .Top = 200
  • .Height = 400
  • .Width = 400
  • .menubar = 0
  • .toolbar = 1
  • .statusBar = 0
  • .navigate2 a
  • .Visible = 1
  • End With
  • if testnet = vbYes then
  • dim t
  • t = time
  • Dim iered
  • If Not IsNull(IE.readystate) Then
  • iered = IE.readystate
  • End If
  • Do While iered < 4
  • iered = IE.readystate
  • Loop
  • dim f
  • f = time
  • '*****je voulais voir les differances de processus*******************************
  • call quickList(false,"2")
  • dim diff
  • diff = minute(f)-minute(t)
  • msgbox f & " - " & t & " = " & diff
  • end if
  • '*******************************************************************************
  • '*******************************************************************************
  • '*******************************************************************************
  • if false then
  • strComputer = "."
  • Set objWMIService = GetObject("winmgmts:" _
  • & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
  • Set colProcessList = objWMIService.ExecQuery _
  • ("Select * from Win32_Process Where Name = 'Notepad.exe'")
  • For Each objProcess in colProcessList
  • objProcess.Terminate()
  • Next
  • end if
  • '*******************************************************************************
  • '*******************************************************************************
  • '*******************************************************************************
  • public sub autreTest()
  • dim wshShell
  • Set WshShell = CreateObject("Wscript.Shell")
  • msgbox "- Nom du processeur : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\ProcessorNameString")
  • msgbox "- Fréquence : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\~mhz")
  • msgbox "- Fabriquant : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\VendorIdentifier")
  • msgbox "- Identifiant du processeur : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier")
  • end sub
  • '*******************************************************************************
  • '***pour la proc pro avoir des mess aulieu de tout ecrire dans un .txt****
  • '*******************************************************************************
  • ' Wscript.echo "handle " & oproc.Handle
  • ' Wscript.echo "caption " & oproc.Caption
  • ' Wscript.echo "CommandLine " & oproc.CommandLine
  • ' Wscript.echo "CSCreationClassName " & oproc.CSCreationClassName
  • ' Wscript.echo "CSName " & oproc.CSName
  • ' Wscript.echo "Description " & oproc.Description
  • ' Wscript.echo "ExecutionState " & oproc.ExecutionState
  • ' Wscript.echo "HandleCount " & oproc.HandleCount
  • ' Wscript.echo "KernelModeTime " & oproc.KernelModeTime
  • ' Wscript.echo "OSName " & oproc.OSName
  • ' Wscript.echo "OtherOperationCount " & oproc.OtherOperationCount
  • ' Wscript.echo " PrivatePageCount " & oproc.PrivatePageCount
  • ' Wscript.echo "ProcessId " & oproc.ProcessId
  • ' Wscript.echo oproc.Name & " = " & oproc.ExecutablePath & " statut "
  • '*******************************************************************************
  • '***********************CREATION DE FICHIER DANS REP TEMP******************
  • '*******************************************************************************
  • Function GetTempFile(File)
  • ' WshShell declaree dans main
  • GetTempFile=WshShell.ExpandEnvironmentStrings("%TEMP%") & "\" & File
  • End Function
  • '*******************************************************************************
  • '*******************************************************************************
  • '*******************************************************************************
  • Public sub jexecute(path)
  • dim executeur
  • set executeur = wscript.createObject("Wscript.shell")
  • executeur.run(path)
  • set executeur = nothing
  • end sub
public sub quickList(arg,suffix)

dim obj
dim fw
dim fname
dim fserv
dim fsw
fname = GetTempFile("listingChampProcessIexp.txt")
fserv = GetTempFile("listingSercices.txt")
Set obj = WScript.CreateObject("Scripting.FileSystemObject")

'*******************************************************************************

if obj.fileExists(fname) then
fname = GetTempFile("listingChampProcessIexp" & suffix & ".txt")
end if

'*******************************************************************************

set fw = obj.createTextFile(fname,true)
set fsw = obj.createTextFile(fserv,true)
Set objWMI = GetObject("winmgmts:root\cimv2")

'*******************************************************************************
    reqVbs = "Select * from Win32_process"
For Each oproc In objWMI.execquery(reqVbs)
if oproc.Name="iexplore.exe" then



fw.writeline "Caption; " & oproc.Caption
fw.writeline   "CommandLine; " & oproc.CommandLine
fw.writeline   "CreationClassName; " & oproc.CreationClassName
fw.writeline   "CreationDate; " & oproc.CreationDate
fw.writeline   "CSCreationClassName; " & oproc.CSCreationClassName
fw.writeline   "CSName; " & oproc.CSName
fw.writeline   "Description; " & oproc.Description
fw.writeline   "ExecutablePath; " & oproc.ExecutablePath
fw.writeline   "ExecutionState; " & oproc.ExecutionState
fw.writeline   "Handle; " & oproc.Handle
fw.writeline   "HandleCount; " & oproc.HandleCount
fw.writeline   "InstallDate; " & oproc.InstallDate
fw.writeline   "KernelModeTime; " & oproc.KernelModeTime
fw.writeline   "MaximumWorkingSetSize; " & oproc.MaximumWorkingSetSize
fw.writeline   "MinimumWorkingSetSize; " & oproc.MinimumWorkingSetSize
fw.writeline   "Name; " & oproc.Name
fw.writeline   "OSCreationClassName; " & oproc.OSCreationClassName
fw.writeline   "OSName; " & oproc.OSName
fw.writeline   "OtherOperationCount; " & oproc.OtherOperationCount
fw.writeline   "OtherTransferCount; " & oproc.OtherTransferCount
fw.writeline   "PageFaults; " & oproc.PageFaults
fw.writeline   "PageFileUsage; " & oproc.PageFileUsage
fw.writeline   "ParentProcessId; " & oproc.ParentProcessId
fw.writeline   "PeakPageFileUsage; " & oproc.PeakPageFileUsage
fw.writeline  "PeakVirtualSize; " & oproc.PeakVirtualSize
fw.writeline   "PeakWorkingSetSize; " & oproc.PeakWorkingSetSize
fw.writeline   "Priority; " & oproc.Priority
fw.writeline   "PrivatePageCount; " & oproc.PrivatePageCount
fw.writeline   "ProcessId; " & oproc.ProcessId
fw.writeline   "QuotaNonPagedPoolUsage; " & oproc.QuotaNonPagedPoolUsage
fw.writeline   "QuotaPagedPoolUsage; " & oproc.QuotaPagedPoolUsage
fw.writeline   "QuotaPeakNonPagedPoolUsage; " & oproc.QuotaPeakNonPagedPoolUsage
fw.writeline   "QuotaPeakPagedPoolUsage; " & oproc.QuotaPeakPagedPoolUsage
fw.writeline   "ReadOperationCount; " & oproc.ReadOperationCount
fw.writeline   "ReadTransferCount; " & oproc.ReadTransferCount
fw.writeline   "SessionId; " & oproc.SessionId
fw.writeline   "Status; " & oproc.Status
fw.writeline   "TerminationDate; " & oproc.TerminationDate
fw.writeline   "ThreadCount; " & oproc.ThreadCount
fw.writeline   "UserModeTime; " & oproc.UserModeTime
fw.writeline   "VirtualSize; " & oproc.VirtualSize
fw.writeline   "WindowsVersion; " & oproc.WindowsVersion
fw.writeline   "WorkingSetSize; " & oproc.WorkingSetSize
fw.writeline   "WriteOperationCount; " & oproc.WriteOperationCount
fw.writeline   "WriteTransferCount; " & oproc.WriteTransferCount


end if ' FIN DE oproc.Name="iexplore.exe"
    Next
call jexecute(fname)

'*******************************************************************************

'*******************************************************************************

if arg then
reqVbs = "select * from win32_service"
For Each oproc In objWMI.execquery(reqVbs)

        'Wscript.echo oproc.Name & " = " & oproc.State
	fsw.writeline oproc.Name & " = " & oproc.State

    Next
call jexecute(fserv)

end if
    
fw.close
fsw.close
Set objWMI = Nothing
set obj = nothing



end sub


'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
public sub pro()

'*******************************************************************************

dim obj
dim fw
dim fname
dim fserv
dim fsw
fname = GetTempFile("listingChampProcessIexp.txt")
fserv = GetTempFile("listingSercices.txt")
Set obj = WScript.CreateObject("Scripting.FileSystemObject")
set fw = obj.createTextFile(fname,true)
set fsw = obj.createTextFile(fserv,true)

Set objWMI = GetObject("winmgmts:root\cimv2")
'*******************************************************************************


if msgbox("liste process",vbyesNo,"liste process") = vbYes then
    reqVbs = "Select * from Win32_process"
For Each oproc In objWMI.execquery(reqVbs)
if oproc.Name="iexplore.exe" then



fw.writeline "Caption; " & oproc.Caption
fw.writeline   "CommandLine; " & oproc.CommandLine
fw.writeline   "CreationClassName; " & oproc.CreationClassName
fw.writeline   "CreationDate; " & oproc.CreationDate
fw.writeline   "CSCreationClassName; " & oproc.CSCreationClassName
fw.writeline   "CSName; " & oproc.CSName
fw.writeline   "Description; " & oproc.Description
fw.writeline   "ExecutablePath; " & oproc.ExecutablePath
fw.writeline   "ExecutionState; " & oproc.ExecutionState
fw.writeline   "Handle; " & oproc.Handle
fw.writeline   "HandleCount; " & oproc.HandleCount
fw.writeline   "InstallDate; " & oproc.InstallDate
fw.writeline   "KernelModeTime; " & oproc.KernelModeTime
fw.writeline   "MaximumWorkingSetSize; " & oproc.MaximumWorkingSetSize
fw.writeline   "MinimumWorkingSetSize; " & oproc.MinimumWorkingSetSize
fw.writeline   "Name; " & oproc.Name
fw.writeline   "OSCreationClassName; " & oproc.OSCreationClassName
fw.writeline   "OSName; " & oproc.OSName
fw.writeline   "OtherOperationCount; " & oproc.OtherOperationCount
fw.writeline   "OtherTransferCount; " & oproc.OtherTransferCount
fw.writeline   "PageFaults; " & oproc.PageFaults
fw.writeline   "PageFileUsage; " & oproc.PageFileUsage
fw.writeline   "ParentProcessId; " & oproc.ParentProcessId
fw.writeline   "PeakPageFileUsage; " & oproc.PeakPageFileUsage
fw.writeline  "PeakVirtualSize; " & oproc.PeakVirtualSize
fw.writeline   "PeakWorkingSetSize; " & oproc.PeakWorkingSetSize
fw.writeline   "Priority; " & oproc.Priority
fw.writeline   "PrivatePageCount; " & oproc.PrivatePageCount
fw.writeline   "ProcessId; " & oproc.ProcessId
fw.writeline   "QuotaNonPagedPoolUsage; " & oproc.QuotaNonPagedPoolUsage
fw.writeline   "QuotaPagedPoolUsage; " & oproc.QuotaPagedPoolUsage
fw.writeline   "QuotaPeakNonPagedPoolUsage; " & oproc.QuotaPeakNonPagedPoolUsage
fw.writeline   "QuotaPeakPagedPoolUsage; " & oproc.QuotaPeakPagedPoolUsage
fw.writeline   "ReadOperationCount; " & oproc.ReadOperationCount
fw.writeline   "ReadTransferCount; " & oproc.ReadTransferCount
fw.writeline   "SessionId; " & oproc.SessionId
fw.writeline   "Status; " & oproc.Status
fw.writeline   "TerminationDate; " & oproc.TerminationDate
fw.writeline   "ThreadCount; " & oproc.ThreadCount
fw.writeline   "UserModeTime; " & oproc.UserModeTime
fw.writeline   "VirtualSize; " & oproc.VirtualSize
fw.writeline   "WindowsVersion; " & oproc.WindowsVersion
fw.writeline   "WorkingSetSize; " & oproc.WorkingSetSize
fw.writeline   "WriteOperationCount; " & oproc.WriteOperationCount
fw.writeline   "WriteTransferCount; " & oproc.WriteTransferCount



end if ' FIN DE oproc.Name="iexplore.exe"
    Next
call jexecute(fname)

'*******************************************************************************


end if ' FIN DE if msgbox("liste process",vbyesNo,"liste process") = vbYes


'*******************************************************************************

if msgbox("liste sercices",vbyesNo,"liste services") = vbYes then
reqVbs = "select * from win32_service"
For Each oproc In objWMI.execquery(reqVbs)

        'Wscript.echo oproc.Name & " = " & oproc.State
	fsw.writeline oproc.Name & " = " & oproc.State

    Next
call jexecute(fserv)

end if
'*******************************************************************************


if msgbox("afficher nom processeur",vbyesNo,"truc acec processor") = vbYes then
reqVbs = "select * from win32_Processor"
For Each oproc In objWMI.execquery(reqVbs)
'if oproc.Name="iexplorer.exe" then
        Wscript.echo oproc.Name & " = " & oproc.ProcessorId
'end if
    Next  
end if
'*******************************************************************************

    
fw.close
fsw.close
Set objWMI = Nothing
set obj = nothing
end sub


'*******************************************************************************
'*******************************************************************************
'*****************METHODE MAIN LA PRINCIPALE QUOI!!!***********************
'*******************************************************************************
'*******************************************************************************
'*******************************************************************************

Dim WshShell,obj
Set WshShell=WScript.CreateObject("WScript.Shell")

if msgbox ("test sur les processus?",vbyesNo,"test processus?") = vbYes then
call pro
end if

if msgbox ("autre test sur les nom de processus?",vbYesNo,"autre test?") = vbYes then
call autreTest
end if

dim testnet
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
testnet = msgbox ("test chrono conexion internet?",vbyesNo,"test net?")
Dim a
a = inputbox("url A tester","url a tester")
if a = "" then a = "http://www.google.fr/"
'*****je voulais voir les differances de processus*******************************
call quickList(false,"")
'************************************************************************************
With IE
        .Left = 200
        .Top = 200
        .Height = 400
        .Width = 400
        .menubar = 0
        .toolbar = 1
        .statusBar = 0
        .navigate2 a
        .Visible = 1
End With

if testnet = vbYes then


dim t
t = time
Dim iered
If Not IsNull(IE.readystate) Then
iered = IE.readystate
End If
Do While iered < 4
iered = IE.readystate
Loop


dim f
f = time

'*****je voulais voir les differances de processus*******************************
call quickList(false,"2")

dim diff
diff = minute(f)-minute(t)

msgbox f & " - " & t & " = " & diff 
end if



'*******************************************************************************
'*******************************************************************************
'*******************************************************************************

if false then
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colProcessList = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'Notepad.exe'")
    
For Each objProcess in colProcessList
    objProcess.Terminate()
Next

end if


'*******************************************************************************
'*******************************************************************************
'*******************************************************************************

public sub autreTest()

dim wshShell
Set WshShell = CreateObject("Wscript.Shell")
    msgbox "- Nom du processeur : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\ProcessorNameString")
    msgbox "- Fréquence : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\~mhz")
    msgbox "- Fabriquant : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\VendorIdentifier")
    msgbox "- Identifiant du processeur : " & WshShell.RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier")



end sub

'*******************************************************************************
'***pour la proc pro avoir des mess aulieu de tout ecrire dans un .txt****
'*******************************************************************************
'	Wscript.echo "handle " & oproc.Handle
'	Wscript.echo "caption " & oproc.Caption
'	Wscript.echo "CommandLine " & oproc.CommandLine
'	Wscript.echo "CSCreationClassName " & oproc.CSCreationClassName
'	Wscript.echo "CSName " & oproc.CSName
'	Wscript.echo "Description " & oproc.Description
'	Wscript.echo "ExecutionState " & oproc.ExecutionState
'	Wscript.echo "HandleCount " & oproc.HandleCount
'	Wscript.echo "KernelModeTime " & oproc.KernelModeTime
'	Wscript.echo "OSName " & oproc.OSName
'	Wscript.echo "OtherOperationCount " & oproc.OtherOperationCount
'	Wscript.echo " PrivatePageCount " & oproc.PrivatePageCount
'	Wscript.echo "ProcessId " & oproc.ProcessId
'       Wscript.echo oproc.Name & " = " & oproc.ExecutablePath & " statut "

'*******************************************************************************
'***********************CREATION DE FICHIER DANS REP TEMP******************
'*******************************************************************************
Function GetTempFile(File)
' WshShell declaree dans main
GetTempFile=WshShell.ExpandEnvironmentStrings("%TEMP%") & "\" & File
End Function
'*******************************************************************************
'*******************************************************************************
'*******************************************************************************
Public sub jexecute(path)
dim executeur
set executeur = wscript.createObject("Wscript.shell")
executeur.run(path)
set executeur = nothing
end sub

 Conclusion

l'important c'est l'utilisation des objets GetObject("winmgmts:root\cimv2") ou CreateObject("InternetExplorer.Application") le reste c'est de la déco


 Sources du même auteur

Source avec Zip COLORATION CONDITIONNELLE
Source avec Zip Source .NET (Dotnet) ANALYSE AUTOMATISÉE
Source avec Zip Source .NET (Dotnet) MISE À JOUR DE BASES DE DONÉES
Source avec Zip OUTIL DE FORMATION
Source avec Zip GEOLOCALISATION WGS84

 Sources de la même categorie

Source avec Zip Source avec une capture RECHERCHE & SAUVEGARDE DES FICHIERS PAR LEURS EXTENSIONS par hackoo
Source avec Zip Source avec une capture [VBS] SPLASH SCREEN EN VBSCRIPT par hackoo
Source avec Zip Source avec une capture [VBS] GOOGLE EASTER EGGS par hackoo
Source avec Zip Source avec une capture FILE2COMPARE: COMPARAISON DE DEUX FICHIERS LIGNE PAR LIGNE par hackoo
Source avec Zip Source avec une capture [VBS] COMMENT CRÉER UN DOSSIER ET LE PROTÉGER PAR MOT DE PAS... par hackoo

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture AUTORISER/REFUSER L'EXECUTION DE PROCESSUS par pierreh51
Source avec Zip Source .NET (Dotnet) LA LISTE DES TÂCHES COMME DANS L'ONGLET APPLICATION DU GESTI... par ShareVB
Source avec Zip FERMER UN PROGRAMME OU UN PROCESSUS par 123collargol
Source avec Zip Source avec une capture Source .NET (Dotnet) COMMENT CONTRÔLER TOTALEMENT LES PROCESSUS D'UN PC DISTANT (... par violent_ken
Source avec Zip Source avec une capture WMI, GESTION D'UNE MACHINE (LOCALE OU DISTANTE) par zesamoth

Commentaires et avis

Commentaire de jack le 27/02/2008 20:40:52 administrateur CS

Si tu veux un exemple complet en VBS :
http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=59348&lngWId=1

Commentaire de PCPT le 28/02/2008 11:19:34 administrateur CS

de plus ici c'est vraiment un vrac de plusieurs résultats qui ont du t'être utile, mais si un débutant tombe la dessus il ne saura pas s'y retrouver correctement
un mélange de wmi, d'accès fichier, de registre...
à la limite pourquoi pas 3VBS + un VBS lanceur ou un BAT, pour mieux séparer chaque action non?

Commentaire de l0r3nz1 le 28/02/2008 13:39:13

Merci pour vos commentaires.

méa culpa.
La prochaine j'arrange les fichier mieux que ça avant avant de le mettre sur ce site.

Pour ceux qui lisent et trouvent que c'est un sacré foutoir mais comme dit la conclusion concentrez vous sur les parties de code tel que
Set objWMI = GetObject("winmgmts:root\cimv2")
    reqVbs = "Select * from Win32_process"
For Each oproc In objWMI.execquery(reqVbs)
if oproc.Name="iexplore.exe" then...

ou

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
ou IE.readystate (renvoi l'etat de la page internet 1,2=debut chargement 3=interactif 4=chargement complet)

@+

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Problème avec Shell [ par FT ] Dans mon code j&#8217;ai une fonction shellAndwait pour attendre la fin du processus. (Je veux lancer un .BAT).Le problème c&#8217;est qu&#8217;avec W VBS et Droits WMI [ par trafalgar ] Bonjour,&nbsp;&nbsp;&nbsp;&nbsp;Je suis en stage au sein d'un lyc&#233;e. Et j'essaye de mettre en place une interface vb&nbsp;Qui lance&nbsp;un scrip VBS, accés distant et Droits WMI [ par trafalgar ] <TABLE id=ctl00_Main_UCContentForum_ctl00_DGMsg style="BORDER-RIGHT: silver 1px solid; BORDER-TOP: silver 1px solid; BORDER-LEFT: silver 1px solid; WI WMI liste processus [ par flopad ] Salut!!Comment est ce que je peux faire pour lister les processus en cours sur une machine distante..??Merci d'avance. la commande shell/récup d'un processus actif [ par Belec ] slt à tous,en espérant que quelqu'un puisse m'éclairer.voila le pb,sous vba + catia je créé un fichier script.(temp.vbscript)ensuite je le lance par u Finalisation d'un script [ par tetard_is_pa ] bon bah je nage complètement, j'ai beau comprendre la logique du If ... Then avec Else ou Case je n'arrive à rien (vivement les cours et la prog sur t Raccourci [ par chrlo ] Bonjour à tousJe débute en VB, j'aimerai forcer un raccourci web (.lnk) à s'ouvrir avec Firefox par défaut. Vous avez une idée ? J'arrive à créer le r Programme agît sur un processus réduit dans la barre de tâche. [ par anerax ] Bonjour all,Existe-t-il une fonction pour qu'un programme vb6 continue d'agir sur un processus réduit ? Merci.Vb6 is'nt dead ! comment éxécuter fichier.reg avec la commande shell ? [ par xpert12 ] Bonjour et merci par avance. Je cherche à lancer le fichier 1.reg en mode caché via la commande Shell. Voici mon code erroné. Quelqu'un peut-il m'ai


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,671 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales