主頁 > 知識庫 > vbs枚舉進(jìn)程 vbs列出進(jìn)程的詳細(xì)列表

vbs枚舉進(jìn)程 vbs列出進(jìn)程的詳細(xì)列表

熱門標(biāo)簽:地圖標(biāo)注政府哪個部門管 除了地圖標(biāo)注還有這種生意嗎 哪里有便宜的地圖標(biāo)注公司 齊齊哈爾高德地圖標(biāo)注店 百度地圖標(biāo)注點(diǎn)距離代碼 東營快遞外呼系統(tǒng) 神行者美術(shù)館地圖標(biāo)注 如何用機(jī)器人進(jìn)行電銷 佛山真人電銷機(jī)器人廠家

今天要說的是用VBS(VBScript腳本)來枚舉Windows操作系統(tǒng)的進(jìn)程,這樣做的用處在什么地方呢?舉個例子吧,比如你有時候想監(jiān)控某個進(jìn)程是否在運(yùn)行,這就非常有用了.

示例:

用VBS腳本枚舉進(jìn)程

'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(13)  Chr(10)
Next
MsgBox Process

我在這兒采用的方式是彈出一個對話框,方便觀看嘛,當(dāng)然你也可以使用FSO來生成一個文本文件保存起來.
前面說到要監(jiān)控某個進(jìn)程是否在運(yùn)行,實(shí)現(xiàn)如下.
示例:

'monitor.vbs
'檢測IE是否在運(yùn)行中
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(13)  Chr(10)
Process = Obj.Description
if Process = "iexplore.exe" then
msgbox "IE在運(yùn)行中..."
end if
Next

呵呵,當(dāng)然,還可以引申出來其它應(yīng)用.

下面給大家分享一個列舉進(jìn)程詳細(xì)列表的vbs

' 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 = "ScreenBufferSize"
dwValue2 = 98304200
strValueName3 = "WindowSize"
dwValue3 = 2818173
strValueName4 = "HistoryNoDup"
dwValue4 = 0
strValueName5 = "WindowPosition"
dwValue5 = 131068
strValueName6 = "QuickEdit"
dwValue6 = 2048
oReg.SetDWORDValue HKEY_CURRENT_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=authorchr(Mystr(i))

Next

WScript.Echo
WScript.Sleep 3000
WScript.Echo "當(dāng)前正在運(yùn)行的進(jìn)程簡要信息列表如下:"
WScript.Echo vbCrLf
WScript.Sleep 2000

Dim MyOBJProcessName
Set OBJWMIProcess = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * From Win32_Process")
     WScript.Echo "Name:        Priority:  PID:  Owner:" vbTabvbTab"ExecutablePath: "
     WScript.Echo "---------------------------------------------------------------------------------------"
         For Each OBJProcess in OBJWMIProcess
     MyOBJProcessName=OBJProcess.Name"          "
         colProperties = OBJProcess.GetOwner(strNameOfUser,strUserDomain)
     WScript.Echo Mid(MyOBJProcessName,1,20) vbTab OBJProcess.Priority vbTab OBJProcess.ProcessID vbTab strNameOfUser vbTabvbTab OBJProcess.ExecutablePath
     Next
    
WScript.Sleep 5000
WScript.Echo vbCrLf
WScript.Echo "當(dāng)前正在運(yùn)行的進(jìn)程以及其加載的模塊詳細(xì)信息樹狀結(jié)構(gòu)如下:"
WScript.Echo vbCrLf
WScript.Sleep 3000
WScript.Echo vbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTabvbTab vbTab"創(chuàng)建時間       文件制造商"

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
  ModulePath = Split(originalPath,"/")
  WMIPathMode = Replace(ModulePath(1),"\","\\")
  Set OBJWMI = GetObject("winmgmts:\\.\root\CIMV2")
  Set colManufacturer = OBJWMI.ExecQuery("SELECT * FROM CIM_DataFile Where Name='"  WMIPathMode  "'")
  For Each OBJManufacturer In colManufacturer
      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=Mid(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.Application") 
objIE.Navigate("about:blank") 
objIE.document.parentwindow.clipboardData.SetData "text", Myclipboard

經(jīng)過測試效果很不錯,喜歡vbs的朋友可以學(xué)習(xí)一下。

標(biāo)簽:邢臺 文山 鶴壁 湖州 銅川 四平 西安 巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《vbs枚舉進(jìn)程 vbs列出進(jìn)程的詳細(xì)列表》,本文關(guān)鍵詞  vbs,枚舉,進(jìn)程,列出,的,詳細(xì),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。

  • 相關(guān)文章
  • 下面列出與本文章《vbs枚舉進(jìn)程 vbs列出進(jìn)程的詳細(xì)列表》相關(guān)的同類信息!
  • 本頁收集關(guān)于vbs枚舉進(jìn)程 vbs列出進(jìn)程的詳細(xì)列表的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章