VBS enumeration Process VBS lists the detailed list of processes _vbs

Source: Internet
Author: User
Tags chr trim

What's the use of using a VBS (VBScript script) to enumerate the Windows operating system's processes today? For example, it's useful to have a process that you sometimes want to monitor for whether it's running.

Example:

Enumerating processes with the VBS script

' Enum.vbs
Dim wmi,objs,process
set Wmi=getobject (' winmgmts: ')
set OBJS=WMI. InstancesOf ("Win32_Process")
process= "for each
Obj in Objs
  process=process & obj.description & CHR & Chr (a)
Next
MsgBox Process

The way I use it here is to pop up a dialog box for easy viewing, but you can also use the FSO to generate a text file to save.
As mentioned earlier, to monitor whether a process is running, implement the following.
Example:

' Monitor.vbs
' detects if IE is running
Dim wmi,objs,process
set Wmi=getobject ("winmgmts:")
set OBJS=WMI. InstancesOf ("Win32_Process")
process= "for each
Obj in Objs
' Process=process & obj.description & Chr & Chr (
a) process = obj.description
If process = "Iexplore.exe" then
MsgBox "ie in operation ..." End
If
Next

Oh, of course, can also be extended out of other applications.

Let's share a VBS that enumerates the detailed list of processes

' FileName:ProcessMagnifier.vbs ' function:capture information about the running processes in detail ' Code by somebody ' qq:240460440 ' lastmodified:2007-12-9 18:50 const HKEY_CURRENT_USER = &h80000001 Set oreg = GetObject ("winmgmts: {Impersonationlevel=impersonate}!\\.\root\default:stdregprov ") strKeyPath =" Console\%systemroot%_system32_ Cmd.exe "Oreg.createkey hkey_current_user,strkeypath strValueName1 =" CodePage "dwValue1 = 936 strValueName2 =" Screenbuf Fersize "dwValue2 = 98304200 StrValueName3 =" windowsize "dwValue3 = 2818173 strValueName4 =" Historynodup "dwValue4 = 0 S TrValueName5 = "Windowposition" dwValue5 = 131068 strValueName6 = "QuickEdit" DwValue6 = 2048 oreg.setdwordvalue Ent_user,strkeypath,strvaluename1,dwvalue1 Oreg.setdwordvalue Hkey_current_user,strkeypath,strvaluename2, DwValue2 oreg.setdwordvalue hkey_current_user,strkeypath,strvaluename3,dwvalue3 Oreg.setdwordvalue HKEY_CURRENT_ User,strkeypath,strvaluename4,dwvalue4 Oreg.setdwordvalue Hkey_currEnt_user,strkeypath,strvaluename5,dwvalue5 Oreg.setdwordvalue Hkey_current_user,strkeypath,strvaluename6, DwValue6 Dim objwsh, finalpath Set objwsh = WScript.CreateObject ("Wscript.Shell") If (Lcase (Right (wscript.fullname,11)) = "Wscript.exe") Then Finalpath = "'" & Wscript.scriptfullname & "" Objwsh.run ("cmd.exe/k cscript//nologo"

&replace (Finalpath, "'", "" ")) Wscript.Quit end If oreg.deletekey HKEY_CURRENT_USER, strKeyPath Set oreg = Nothing Wscript.Sleep 1000 mystr = Array (115,111,109,101,98,111,100,121) for i=0 to Ubound (mystr) author=author&chr (Mystr (i ) Next WScript.Echo Wscript.Sleep 3000 WScript.Echo "The current running Process summary Information list is as follows: WScript.Echo vbCrLf wscript.sleep \ Dim my Objprocessname Set objwmiprocess = GetObject ("winmgmts:\\.\root\cimv2"). ExecQuery ("SELECT * from Win32_Process") wscript.echo "Name:Priority:PID:Owner:" &vbtab&vbtab&amp ;" ExecutablePath: "WScript.Echo"---------------------------------------------------------------------------------------"For each objprocess in objwmiprocess myobjprocessname=objprocess.name& "" Colproperties = Objprocess.getowner (Strnameofuser,struserdomain) WScript.Echo Mid (MYOBJPROCESSN ame,1,20) &vbTab& objprocess.priority &vbTab& objprocess.processid &vbTab& strnameofuser &vbTab&vbTab& Objprocess.executablepath Next Wscript.Sleep 5000 wscript.echo vbCrLf WScript.Echo "Current The running process and its loaded module details tree structure is as follows: "WScript.Echo VbCrLf Wscript.Sleep 3000 WScript.Echo Vbtab&vbtab&vbtab&vbtab &vbtab&vbtab&vbtab&vbtab&vbtab&vbtab&vbtab&vbtab&vbtab&vbtab&vbtab &vbTab& vbtab& "Create time file Manufacturer" Set objWMIService = GetObject ("winmgmts:{impersonationlevel=impersonate}!\\. \root\cimv2 ") Set Objrefresher = CreateObject (" Wbemscripting.swbemrefresher ") Set colitems = Objrefresher.addenum ( objWMIService, "Win32_perfformatteddata_perfproc_fullimage_coStly ").  Objectset Objrefresher.refresh for each objitem in colitems Dim originalpath, Modulepath, Wmipathmode, FileManufacturer, Lcasemodulepath Dim FileExtension, Mark, Mylcasemodulepath, Finalmodulepath originalpath = objItem.Name ModulePat h = Split (Originalpath, "/") Wmipathmode = Replace (Modulepath (1), "\", "\") Set Objwmi = GetObject ("Winmgmts:\\.\root\ci MV2 ") Set colmanufacturer = Objwmi. ExecQuery ("SELECT * from Cim_datafile Where name= '" & Wmipathmode & "") for each objmanufacturer in Colmanufact
      Urer Filemanufacturer=trim (objmanufacturer.manufacturer) lcasemodulepath=lcase (Trim (objmanufacturer.name))                                                        Fileextension=right (Lcasemodulepath, 3) Mylcasemodulepath=lcasemodulepath & " "Set FSO = CreateObject (" Scripting.FileSystemObject "). GetFile (Lcasemodulepath) If fileextension= "EXE" Then mark= "├-" Finalmodulepath=mi D (Mylcasemodulepath,1,118) WScript.Echo "│" Else mark= "│├─" finalmodulepath= Mid (mylcasemodulepath,1,116) End If wscript.echo Mark & Finalmodulepath & FSO. DateCreated &vbTab& filemanufacturer Next Next Myvbspath = "'" & Wscript.scriptfullname ; "'" Myclipboard = "cscript//nologo" & Replace (Myvbspath, "'", "" ") Set objIE = CreateObject (" Internetexplorer.app
 Lication ") objie.navigate (" About:blank ") objIE.document.parentwindow.clipboardData.SetData" text ", Myclipboard

The test results are very good, like a friend of VBS can learn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.