Login | |
|
 |
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
|
|
| |
|
|
|
 |
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."
|
|
| |
|
|
|
 |
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."
|
|
| |
|
|
|
 |
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."
|
|
| |
|
|
|
 |
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"
|
|
| |
|
|
|
 |
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 >
|
|
| |
|
|
|
 |
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."
|
|
| |
|
|
|
 |
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 >
|
|
| |
|
|
|
 |
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.
|
|
| |
|
|
|
 |
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.
|
|
| |
|
|
|
 |
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!
|
|
| |
|
|
|
 |
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."
|
|
| |
|
|
|
 |
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."
|
|
| |
|
|
|
|
|