Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Task Manager

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,28532
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Task Manager
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 RE: Task Manager - 12/7/2005 6:51:12 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
Well, as for formatting, it depends on what you are outputting to. If you output to a plain text file, then no because plain text does not support formatting. If you use word to create the output or you output HTML then yes you can format the output. As for how to open the file created, I don't know. Your code is what creates the file, so you should know what you are outputting the results to. Post the code as it is now and we can see how you are outputting the result.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blake.arnold)
 
 
Post #: 21
 
 RE: Task Manager - 12/7/2005 7:04:46 AM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
Option Explicit
Dim SWBemlocator, objWMIService, colProcesses1, colItems, colProcess, UserName
Dim oProcDic, strProc, objfso, objList, strProcess, objItem, strComputer, Password
Dim numPPsrTTot, colPageFiles, objPageFile


strComputer = "."
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"\root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_PerfProc_Process",,48)
Set colProcesses1 = objWMIService.ExecQuery _
  ("SELECT * FROM Win32_PerfRawData_PerfProc_Process where Name = '_Total'")
Set colPageFiles = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfOS_Memory",,48)

Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
Set oProcDic = CreateObject("Scripting.Dictionary")
For Each strProc In colProcess
    If oProcDic.Exists(strProc.ProcessID) Then
        objList.WriteLine "DUPLICATE PROCESSID FOR " & strProc.ProcessID
    Else
        oProcDic.Add strProc.ProcessID, CreateObject("Scripting.Dictionary")
        oProcDic(strProc.ProcessID).Add "Name", strProc.Name
        oProcDic(strProc.ProcessID).Add "MEM", strProc.WorkingSetSize/1024
    End If
Next

Set objfso = CreateObject("Scripting.FileSystemObject")
Set objList = objfso.CreateTextFile("c:\test.txt")


objList.WriteLine ColumnFormat(Array("Running Processes:", "Memory Usage:", "CPU Usage:"), 30, "L")
ObjList.WriteLine ""

For Each strProcess in colProcesses1
    numPPsrTTot = strProcess.PercentProcessorTime
Next

For Each objItem in colItems
    If oProcDic.Exists(objItem.IDProcess) Then
        If oProcDic(objItem.IDProcess).Exists("%CPU") Then
            oProcDic(objItem.IDProcess)("%CPU") = FormatNumber(objItem.PercentProcessorTime/numPPsrTTot,4,,,-1)*100
        Else
            oProcDic(objItem.IDProcess).Add "%CPU", FormatNumber(objItem.PercentProcessorTime/numPPsrTTot,4,,,-1)*100
        End If
    Else
        objList.WriteLine "WAS NOT IN PROCDIC: " & objItem.IDProcess & " - " & objItem.Name
    End If
Next

For Each strProc In oProcDic.Keys()
    objList.WriteLine ColumnFormat(Array(oProcDic(strProc)("Name"), oProcDic(strProc)("MEM") & "KB", _
        FormatNumber(oProcDic(strProc)("%CPU"),0) & "%"), 30, "L")
   
Next

For Each objPageFile in colPageFiles
        ObjList.WriteLine ""
        objList.WriteLine ColumnFormat(Array("Page File Usage:"), 30, "L")
        ObjList.WriteLine ""
        objList.WriteLine ColumnFormat(Array(FormatNumber(objPageFile.CommittedBytes/(1024*1024),1) & "MB"), 30, "L")
Next

objList.Close


Function ColumnFormat(arrItems, nColumnSize, strJustification)
    Dim strFront
    Dim strBack
    Dim strReturn
    Dim i
   
    strReturn = ""
    'Make sure none of the items are bigger than column size
    For i = LBound(arrItems) To UBound(arrItems)
        If Len(arrItems(i)) > nColumnSize Then arrItems(i) = Left(arrItems(i), nColumnSize)
        Select Case UCase(strJustification)
            Case "L"
                strReturn = strReturn & arrItems(i) & Space(nColumnSize - Len(arrItems(i)))
            Case "R"
                strReturn = strReturn & Space(nColumnSize - Len(arrItems(i))) & arrItems(i)
            Case "C"
                strFront = Space(Int((nColumnSize-Len(arrItems(i)))/2))
                strBack = Space(Int((nColumnSize-Len(arrItems(i)))/2) + (nColumnSize-Len(arrItems(i))) Mod 2)
                strReturn = strReturn & strFront & arrItems(i) & strBack
        End Select
    Next
    ColumnFormat = strReturn
End Function

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to ebgreen)
 
 
Post #: 22
 
 RE: Task Manager - 12/7/2005 7:06:07 AM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
I want to either make my text bold or enlarge the size of the headers font.  That is the type of formating that I need.

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to blake.arnold)
 
 
Post #: 23
 
 RE: Task Manager - 12/7/2005 7:44:50 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
This will output it to an html file that you can open from any browser (just couble click on the file c:\Test.html after the script completes).


      

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to blake.arnold)
 
 
Post #: 24
 
 RE: Task Manager - 12/7/2005 11:22:59 PM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
But can I make the script open the file that was created?  So that I don't have to browse to it, it just opens when the script is done.

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to ebgreen)
 
 
Post #: 25
 
 RE: Task Manager - 12/8/2005 1:55:14 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
You should be able to just add:

Set oShell = CreateObject("Wscript.Shell")
oShell.Run "c:\test.html"

(in reply to blake.arnold)
 
 
Post #: 26
 
 RE: Task Manager - 12/8/2005 11:51:20 PM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
Now it is starting to come together.  One problem when I try to add this "<td width="220" align='" & strAlign & "'>"  in the function it will just error out.  And when I try to add it to the table line like so "<table cellpadding=3><tr><td width="220"><strong>Running Processes:</strong></td><td><strong>Memory Usage:</strong></td><td><strong>CPU Usage:</strong></td></tr>"  it just errors out.  So I created a html page and wrote the following, and it worked.  So what do I need to do to the script to make it work?

      


 

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to Country73)
 
 
Post #: 27
 
 RE: Task Manager - 12/9/2005 1:13:32 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
It is hard to say without seeing the rest of the code.  If you comment out this little section does it work right?
The are contained in something like objLogFile.Writeline right?

I guess I am asking if the creation of the html is dynamic from the script?  Because your post is not clear.  If you are following ebgreen's example you should be ok, but you need to post you script in order for us to see where any problems are.


Cybex

< Message edited by Cybex -- 12/9/2005 1:22:44 AM >

(in reply to blake.arnold)
 
 
Post #: 28
 
 RE: Task Manager - 12/9/2005 1:28:45 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
This should work for that problem:


      

By the way chr(34) = "

(in reply to blake.arnold)
 
 
Post #: 29
 
 RE: Task Manager - 12/9/2005 1:41:16 AM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
Country73 that worked great but what is the chr(34) for?

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to Country73)
 
 
Post #: 30
 
 RE: Task Manager - 12/9/2005 1:48:40 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
chr(34) is the chr() for an ASCII double quote.

Cybex

< Message edited by Cybex -- 12/9/2005 1:50:06 AM >

(in reply to blake.arnold)
 
 
Post #: 31
 
 RE: Task Manager - 12/9/2005 2:20:39 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Cybex got to it before I was able to post back... but look at the bottom of my post (below the code window).

Glad to help out.

(in reply to blake.arnold)
 
 
Post #: 32
 
 RE: Task Manager - 12/9/2005 2:23:19 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Hey, you have to leave some of the easy ones for us to answer.


Cybex

_____________________________

Common sense is not so common.

(in reply to Country73)
 
 
Post #: 33
 
 RE: Task Manager - 12/9/2005 2:26:35 AM   
  Country73


Posts: 733
Score: 10
Joined: 8/25/2004
From: USA
Status: offline
Hey, I enjoy the easy ones just as much as the next guy!

(in reply to Cybex)
 
 
Post #: 34
 
 RE: Task Manager - 12/11/2005 12:23:03 AM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
Ok next hard one.  How can I get the version of Windows Media Player?

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to Country73)
 
 
Post #: 35
 
 RE: Task Manager - 12/11/2005 12:31:07 AM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
I frogot that I need the version of Internet Explorer also.

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to blake.arnold)
 
 
Post #: 36
 
 RE: Task Manager - 12/11/2005 11:55:51 PM   
  blake.arnold


Posts: 31
Score: 0
Joined: 12/1/2005
Status: offline
I did figure out how to get the version of IE.  However I still dont know how to get the version of Windows Media Player.
This is the code for IE if anyone needs it.

      

_____________________________

"And what is a weed? A plant whose virtues have not yet been discovered."

(in reply to blake.arnold)
 
 
Post #: 37
 
 
Page:  <<   < prev  1 [2]
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Task Manager Page: <<   < prev  1 [2]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts