Jump to content

can i have a little help with a vbs script please?


Recommended Posts

If you have a printer on the network does it pick it up. The hta has gotten to bif to post the code now, it 811 lines long now. Is there any other hardware that should be check for. Is there any information you think I may be missing. Is this what you wanted for the information.

Link to comment
Share on other sites


I'll take a peek at it today or tommorow. Depends on how far along I get cleaning up a mess at work.
Thanks

I was thinking of some thing like this to add to the HTA

Save As TestListProcess.hta

<HEAD><TITLE>   Gsm_List Process</TITLE>
<HTA:APPLICATION ID="Gsm_List Process" SCROLL="Yes" SCROLLFLAT ="No" SingleInstance="Yes"
ShowInTaskbar="Yes" SysMenu="No" Border="Thin" BORDERSTYLE ="complex" INNERBORDER ="No"
Caption="Yes" WindowState="Normal" APPLICATIONNAME="Gsm_List Process">
<!-- ================================================ -->
<style>
/* BODY CSS STYLE */
Body.Normal
{8.25pt Palatino Linotype; color:#000080;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#e8e4de', EndColorStr='#c7c3be')}

/* GENERAL CSS STYLE USED BY THE TBODY CLASS */
.TKT2
{font-size:10.75pt;font-family:Palatino-Linotype;font-weight:Bold-Italic;line-height:110%;
color:#0926ed;background-color:#c7c3be;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');padding-top:3;padding-bottom:3;
padding-left:8;padding-right:8;margin-right:8;}

/* BUTTON CSS STYLE */
.BTN1
{font-size:9.75pt;font-family:Palatino-Linotype;font-weight:Bold-Italic;line-height:110%;
color:#008000;background-color:;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');padding-top:2;padding-bottom:2;
padding-left:2;padding-right:2;margin-right:2;Width:95;Height:25;}

/*TD CSS STYLE */
TD.BTN2
{font-size:9.75pt;font-family:Palatino-Linotype;font-weight:Bold-Italic;line-height:110%;
color:#008000;background-color:;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');padding-top:3;padding-bottom:3;
padding-left:8;padding-right:8;margin-right:8;}
</style>
<!-- ================================================ -->
<script LANGUAGE = "VBScript"> window.resizeTo 520,705
Const ForReading = 1, ForWriting = 2,ForAppending = 8
Dim Act, Fso, FR_Name, MB, Mem, Sd, SP_PID, SP_Name, strComputer, Tkill, Ts, Txt_Line, Uname

Set Fso = CreateObject("Scripting.FileSystemObject")
Set Act = CreateObject("Wscript.Shell")

Sd = Act.ExpandEnvironmentStrings("%SystemDrive%") : Uname = Act.ExpandEnvironmentStrings("%UserName%")
strComputer = "." : MB = 1024 * 1024

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Function window_onLoad
GetInfo : iTimerID = window.setInterval("GetInfo", 300, "VBScript")
Lb1.InnerHtml = Uname & "<BR> Process List"
End Function

Function GetInfo
' // --> LOOP TO UPDATE THE DISPLAY
For i = (objTable.Rows.Length - 1) to 0 Step -1
myNewRow = document.all.objTable.deleteRow(i)
Next
' // --> LABELS FOR PID PROCES NAME MEMORY USAGE
Set objRow = objTableBody.InsertRow() : objRow.Style.fontWeight = "Bold"
Set objRow = objTable.InsertRow() : objRow.Style.Color = "Red"
Set objCell = objRow.InsertCell() : objCell.InnerText = "Process ID"
Set objCell = objRow.InsertCell() : objCell.InnerText = "Process Name"
Set objCell = objRow.InsertCell() : objCell.InnerText = "Memory Usage"

' // --> WMI PROCESS CLASS
Set colProcesses = objWMIService.ExecQuery("SELECT * FROM Win32_Process")

' // --> LOOP TO COLLECT THE PID, NAME, MEMORY
For Each strProcess in colProcesses
SP_PID = strProcess.ProcessID : SP_Name = strProcess.Name
FR_Name = FormatNumber(strProcess.WorkingSetSize,0,,,-1) /1024
Txt_Line = Space(5) & SP_PID & space(5) & SP_Name & space(5) & FR_Name

' // --> DISPLAYS THE PID PROCES NAME MEMORY USAGE
Set objRow = objTableBody.InsertRow()
Set objCell = objRow.InsertCell()
objRow.Style.Color = "#0000C8"
objRow.Style.fontWeight = "Bold"
objCell.InnerText = strProcess.ProcessID

Set objCell = objRow.InsertCell() : objCell.InnerText = strProcess.Name

Set objCell = objRow.InsertCell()
Mem = FormatNumber(strProcess.WorkingSetSize,0,,,-1) / MB
Mem = Left(Mem,4) : objCell.InnerText = Mem & " Mb"
Next
End Function

Function KillTask
Tkill = InputBox("Type In The Name Of The Process To Kill","Task Kill Process",,5500,4800)
If Tkill = "" Then : window.Alert "User Has cancel Task Kill" : End If
If Tkill <> "" Then
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = '" & Tkill & "'")
For Each objProcess in colProcessList : objProcess.Terminate() : Next
End If
Exit Function
End Function

Function HTAEXIT
' // --> THIS IS FOR IF THE FILE WAS IN A SFX FILE,
' If Fso.FileExists(Sd & "\listprocess.hta") Then : Fso.DeleteFile(Sd & "\listprocess.hta") : End If
Window.close
Exit Function
End Function
</SCRIPT></Head>
<!-- ================================================ -->
<body SCROLL="Yes" CLASS="Normal"><Table WIDTH="455" ALIGN="Center">
<TD CLASS="BTN2"><TABLE WIDTH="425" ALIGN="Center">
<TD><input TYPE="button" LANGUAGE="vbscript" VALUE="Kill Process" CLASS="BTN1" ONCLICK="KillTask"></TD>
<TD> </TD>
<TD CLASS="BTN2" WIDTH="275" ALIGN="Center"><SPAN ID="Lb1"></SPAN></TD>
<TD> </TD>
<TD><input TYPE="button" LANGUAGE="vbscript" VALUE="Exit App" CLASS="BTN1" ONCLICK="HTAEXIT"></TD></Table>
<TABLE ID ="objTable" CLASS="TKT2" Width="425"><TBODY ID ="objTableBody" CLASS="TKT2" Width="425">
</TBODY></TD></TABLE>
<TD> </TD>
<Table ALIGN="Center"><TD>
<input TYPE="button" LANGUAGE="vbscript" VALUE="Kill Process" CLASS="BTN1" ONCLICK="KillTask">
</TD></Table></Body>

Yzöwl these where never in the script <TR> and </TR>

I did this in under a hour and made it only so it would work, I have now edit it to remove redundant stuff.

I have 117 lines for the whole script, including comments and spaces.

In VBS : that like a new line, and since none my lines exceed 120 to the right this a acceptable practice.

Space this out so you could see what missing the green does not show with out the spaces

It missing  & # 160 ; between the <TD> </TD>

Edited by gunsmokingman
Link to comment
Share on other sites

wow! that in itself is a cool little app :)

i think if you was thinking of that kind of control (e.g stopping process's remotely) it should be a sepertate file because it might screw it up when you save the .hta and reopen it and try to end a task thats not there.

as far as what else the script needs:

the total ram - from win32_logicalmemoryconfiguration

make model + serial number from win32_computersystemproduct

pagefile location/s?? from win32_pagefile <- would this be useful?

scsi controller make + model from win32_scsicontroller

tapedrive make + model from win32_tapedrive

that would be it, i would like to see how many memory banks a pc has and which ones are empty but i cant find a WMI class that lists this information, i'l google it and post back but i have looked before without much luck

thank you

set oSvc = GetObject("winmgmts:\root\cimv2") 
set oArrays = oSvc.ExecQuery("select * from Win32_PhysicalMemoryArray")
for each slots in oArrays
wscript.echo slots.Tag & " has " & slots.MemoryDevices & "slots/sockets."
next

this gives you the number of memory slots but unfortunatly doesnt tell you what memory is in what slot, ill look into this further...

EDIT: here is a script that tells you what memory bank has memory in it and how much :)

strComputer = inputbox("Enter Computer Name")
'Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

sData = "[Physical Memory]" & vbCrLf
sData = sData & "Bank Label, Capacity, Description," _
& "DeviceLocator, DataWidth, FormFactor" & vbCrLf

for each memory in oWMI.InstancesOf("Win32_PhysicalMemory")
counter = counter + 1
sData = sData & memory.BankLabel & "," & CStr(memory.capacity) _
& "," & memory.Description & "," & memory.DeviceLocator _
& "," & memory.DataWidth & "," & memory.FormFactor & vbCrLf
next
wscript.echo counter
wscript.echo sData

maybe you can do something with these two scripts Gunsmlokingman? :D

Edited by eyeball
Link to comment
Share on other sites

I do have the total ram in the script

I will add the 1 script you have posted to the hta.

I will be adding the second one as I am not sure what the heck the first reports :blushing:

You should also look at Microsoft for a thing called the WMI Code Creator, that what I when using the WMI class.

Here is a edit of the code you posted.

' // --> Script By EyeBall re-edit by Gunsmokingman 
strComputer = "."
Dim MB : MB = 1024 * 1024

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Dim ObjRam, RamTotal, strRam , sData
Set strRam = objWMIService.ExecQuery( "SELECT * FROM Win32_PhysicalMemory")
for each ObjRam in strRam
RamTotal = RamTotal + strRam.count
sData = sData & vbcrlf & "Bank Label : " & ObjRam.BankLabel &_
vbcrlf & "Capacity : " & Left(Round(ObjRam.capacity / MB ,5),5) &_
vbcrlf & "Description : " & ObjRam.Description &_
vbcrlf & "Device Locator : " & ObjRam.DeviceLocator &_
vbcrlf & "Ram Label : " & ObjRam.Tag &_
vbcrlf & "Form Factor : " & ObjRam.FormFactor &_
vbcrlf & "Ram Slot Number : " & RamTotal & vbCrLf & "----------------------------"
Next

WScript.Echo sData & vbCrLf & "Total Ram Slots : " & RamTotal

Edited by gunsmokingman
Link to comment
Share on other sites

<snip>

TestListProcess.hta

<snip>

As much as I love this stuff, why is it that I find your code so difficult to read?

Is there a 'code prettier' in vbsedit?

This is what I've done to it to make it more readable to me!

<HEAD>
<TITLE>Gsm_List Process</TITLE>
<HTA:APPLICATION
ID="Gsm_List Process"
SYSMENU="Yes"
SCROLL="Yes"
SCROLLFLAT="No"
SINGLEINSTANCE="Yes"
SHOWINTASKBAR="Yes"
SYSMENU="No"
MAXIMIZEBUTTON="No"
MINIMIZEBUTTON="Yes"
BORDER="Thin"
BORDERSTYLE="Complex"
INNERBORDER="No"
CAPTION="Yes"
WINDOWSTATE="Normal"
APPLICATIONNAME="Gsm_List Process"
ICON="http://www3.telus.net/GSMJAK1E/AUABuilder/BgImgs/Hta2.ico"
>
</HEAD>
<HTML
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40"
>
<!--[if !mso]>
<STYLE>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}.shape
{behavior:url(#default#VML);}
</STYLE>
<![endif]-->
<!--[if gte mso 9]>
<XML>
<o:DocumentProperties>
</w:LatentStyles>
</XML>
<![endif]-->
<STYLE>
.TKT2{
font-size:10.75pt;
font-family:Palatino-Linotype;
font-weight:Bold-Italic;
line-height:110%;
color:#0926ed;
background-color:#c7c3be;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');
padding-top:3;
padding-bottom:3;
padding-left:8;
padding-right:8;
margin-right:8;
}
.BTN1{
font-size:9.75pt;
font-family:Palatino-Linotype;
font-weight:Bold-Italic;
line-height:110%;
color:#008000;
background-color:;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');
padding-top:3;
padding-bottom:3;
padding-left:8;
padding-right:8;
margin-right:8;
width:125;
}
TD.BTN2{
font-size:9.75pt;
font-family:Palatino-Linotype;
font-weight:Bold-Italic;
line-height:110%;
color:#008000;
background-color:;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');
padding-top:3;
padding-bottom:3;
padding-left:8;
padding-right:8;
margin-right:8;
width:175;
}
</STYLE>
<!--[if gte mso 10]><STYLE></STYLE><![endif]-->
<!-- ======================== SCRIPT SEPARATOR ======================== -->
<script LANGUAGE="VBScript">
Window.resizeto 520,705
Const forreading=1, forwriting=2, forappending=8
Dim inta
inta=0
Dim sp_pid, sp_name, fr_name, txt_line, mb, act, dtop, fso, ts, uname
Set act=Createobject("Wscript.Shell")
Set fso=Createobject("Scripting.Filesystemobject")
dtop=act.specialfolders("Desktop")
uname=act.expandenvironmentstrings("%Username%")
strcomputer="."
Set objwmiservice=Getobject("Winmgmts:{Impersonationlevel=Impersonate}!\\" _
&strcomputer &"\Root\Cimv2")
Set colprocesses=objwmiservice.execquery("Select * From Win32_Process")
mb=1024 * 1024
''''
Sub window_onload
getinfo
itimerid=Window.setinterval("Getinfo", 300, "Vbscript")
lb1.innerhtml=uname &"<BR> Process List"
End Sub
''''
Sub getinfo
For i=(objtable.rows.length - 1) To 0 Step -1
mynewrow=Document.all.objtable.deleterow(i)
Next
Set objrow=objtablebody.insertrow()
objrow.style.fontweight="Bold"
Set objrow=objtable.insertrow()
objrow.style.color="Red"
Set objcell=objrow.insertcell()
objcell.innertext="Process ID"
Set objcell=objrow.insertcell()
objcell.innertext="Process Name"
Set objcell=objrow.insertcell()
objcell.innertext="Working Set Size"
Set colprocesses=objwmiservice.execquery("Select * From Win32_Process")
For Each strprocess In colprocesses
sp_pid=strprocess.processid
sp_name=strprocess.name
fr_name=Formatnumber(strprocess.workingsetsize,0,,,-1) /1024
txt_line=Space(5) &sp_pid &Space(5) &sp_name &Space(5) &fr_name
Set objrow=objtablebody.insertrow()
Set objcell=objrow.insertcell()
objrow.style.color="#0000c8"
objrow.style.fontweight="Bold"
objcell.innertext=strprocess.processid
Set objcell=objrow.insertcell()
objcell.innertext=strprocess.name
Set objcell=objrow.insertcell()
mem=Formatnumber(strprocess.workingsetsize,0,,,-1) / mb
mem=Left(mem,4)
objcell.innertext=mem &" Mb"
Next
End Sub
Function killtask
strcomputer="."
Dim tkill
tkill=Inputbox("Type In The Name Of The Process To Kill", _
"Task Kill Process",,5500,4800)
If tkill="" Then
Window.alert "User Has Cancelled Task Kill"
End If
If tkill <> "" Then
Window.alert "Preparing To Taskkill, " &tkill
Set objwmiservice=Getobject _
("Winmgmts:{Impersonationlevel=Impersonate}!\\" &strcomputer _
&"\Root\Cimv2")
Set colprocesslist=objwmiservice.execquery _
("Select * From Win32_Process Where Name='" &tkill &"'")
For Each objprocess In colprocesslist
objprocess.terminate()
Next
End If
Exit Function
End Function
Function htaexit
If fso.fileexists("Listprocess.Hta") Then
fso.deletefile("Listprocess.Hta")
End If
Window.close
Exit Function
End Function
</SCRIPT>
<BODY
SCROLL="Yes"
STYLE="8.25pt Palatino Linotype;
color:#000080;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#e8e4de', EndColorStr='#c7c3be')"
>
<TABLE WIDTH="455" ALIGN="Center">
<TR>
<TD CLASS="BTN2">
<TABLE WIDTH="425" ALIGN="Center">
<TR>
<TD>
<INPUT
TYPE="Button"
LANGUAGE="Vbscript"
VALUE="Task Kill Process"
CLASS="BTN1"
TITLE=""
ONCLICK="KillTask"
>
</TD>
<TD>
</TD>
<TD CLASS="BTN2" WIDTH="275" ALIGN="Center">
<SPAN ID="Lb1">
</SPAN>
</TD>
<TD>
</TD>
<TD>
<INPUT
TYPE="Button"
LANGUAGE="Vbscript"
VALUE="Exit App"
CLASS="BTN1"
TITLE=""
ONCLICK="HTAEXIT"
>
</TD>
</TR>
</TABLE>
<CENTER>
<TABLE ID="objTable" CLASS="TKT2" WIDTH="425">
<TBODY ID="objTableBody" CLASS="TKT2" WIDTH="425">
</TBODY>
</TABLE>
</CENTER>
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD HEIGHT="15">
</TD>
</TR>
</TABLE>
<TABLE ALIGN="Center">
<TR>
<TD>
<INPUT
TYPE="Button"
LANGUAGE="Vbscript"
VALUE="Task Kill Process"
CLASS="BTN1"
TITLE=""
ONCLICK="KillTask"
>
</TD>
</TR>
</TABLE>

Which one is best for who is down to individuals, but for me as a relative learner, I prefer my way. Comments please…

<Edit>

Updated to remove the initial unnecessary <HTML> tag, include several missing <TR> and </TR> tags and a missing </CENTER> tag, replace an incorrect </TABLE> tag with a </TD> tag and change some code character Case.

None of this stuff I noticed in the original format.

</Edit>

Edited by Yzöwl
Link to comment
Share on other sites

Thanks Yzöwl, I like what you did. Since I am dislexic I find it easier for me to read things as a whole line, when it display the way you have it, I get lost.

Example

If I am looking at line 10 and it goes to line 15 the object, I may be reading line 21 as line 15. I used to try and do it the way you have it but it cause me to get a lot of errors. So to me I find what you coded hard to read.

Edited by gunsmokingman
Link to comment
Share on other sites

Hi GSM, Long time no see.

I've been off in other worlds, but thought I'd drop by and see if any of my old friends were around.

You're gettin really good at this stuff, pal. Nice work.

Hopefully I'll get some time to drop in more often.

Be well, c ya round......

Link to comment
Share on other sites

the way Yzöwl displayed it was easier to read for me, but i can manage reading the old one,

we need to add to this script the ability to scan a range of IP address's as at the minute you have to scan each one individually, can we take this from the original script i posted in the first post? if no one has had a look by the time i return from work ill take a look at doing this

thanks

Link to comment
Share on other sites

Hey I was wondering if a extra script in JS that would make the list process HTA would be ok. I then could have a button to run the js script, from the main HTA.

What I would like to add to the SFX File

Save as MKListProcess.Js

var Act, Drv, fso , File;
fso = new ActiveXObject("Scripting.FileSystemObject");
Act = new ActiveXObject("Wscript.Shell");
File = Act.ExpandEnvironmentStrings("%SystemDrive%\\ListProcess.hta");
var a = fso.CreateTextFile(File, true);
a.writeline (" <HEAD><TITLE> Gsm_List Process</TITLE>");
a.writeline (" <HTA:APPLICATION ID= \"Gsm_List Process\" SCROLL= \"Yes\" SCROLLFLAT =\"No\" SingleInstance= \"Yes\" ");
a.writeline (" ShowInTaskbar=\"Yes\" SysMenu= \" No \" Border= \" Thin \" BORDERSTYLE = \" complex \" INNERBORDER =\"No\" ");
a.writeline (" Caption=\"Yes\" WindowState=\"Normal\" APPLICATIONNAME=\"Gsm_List Process\">");
a.writeline ("<!-- ================================================ -->");
a.writeline (" <style>");
a.writeline (" /* BODY CSS STYLE */");
a.writeline (" Body.Normal");
a.writeline (" {8.25pt Palatino Linotype; color:#000080;filter:progid:DXImageTransform.Microsoft.Gradient");
a.writeline (" (GradientType=0, StartColorStr='#e8e4de', EndColorStr='#c7c3be')}");
a.writeline (" /* GENERAL CSS STYLE USED BY THE TBODY CLASS */");
a.writeline (" .TKT2");
a.writeline (" {font-size:10.75pt;font-family:Palatino-Linotype;font-weight:Bold-Italic;line-height:110%;");
a.writeline (" color:#0926ed;background-color:#c7c3be;filter:progid:DXImageTransform.Microsoft.Gradient");
a.writeline (" (GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');padding-top:3;padding-bottom:3;");
a.writeline (" padding-left:8;padding-right:8;margin-right:8;}");
a.writeline (" /* BUTTON CSS STYLE */ ");
a.writeline (" .BTN1");
a.writeline (" {font-size:9.75pt;font-family:Palatino-Linotype;font-weight:Bold-Italic;line-height:110%;");
a.writeline (" color:#008000;background-color:;filter:progid:DXImageTransform.Microsoft.Gradient");
a.writeline (" (GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');padding-top:2;padding-bottom:2;");
a.writeline (" padding-left:2;padding-right:2;margin-right:2;Width:95;Height:25;}");
a.writeline (" /*TD CSS STYLE */ ");
a.writeline (" TD.BTN2");
a.writeline (" {font-size:9.75pt;font-family:Palatino-Linotype;font-weight:Bold-Italic;line-height:110%;");
a.writeline (" color:#008000;background-color:;filter:progid:DXImageTransform.Microsoft.Gradient");
a.writeline (" (GradientType=0,StartColorStr='#c7c3be',endColorStr='#e8e4de');padding-top:3;padding-bottom:3;");
a.writeline (" padding-left:8;padding-right:8;margin-right:8;}");
a.writeline (" </style>");
a.writeline ("<!-- ================================================ -->");
a.writeline ("<script LANGUAGE = \"VBScript\"> window.resizeTo 520,705");
a.writeline (" Dim Act, Fso, FR_Name, MB, Mem, Sd, SP_PID, SP_Name, strComputer, Tkill, Ts, Txt_Line, Uname");
a.writeline (" Set Fso = CreateObject( \"Scripting.FileSystemObject\" )");
a.writeline (" Set Act = CreateObject( \"Wscript.Shell\" )");
a.writeline (" Sd = Act.ExpandEnvironmentStrings( \"%SystemDrive%\" ) : Uname = Act.ExpandEnvironmentStrings(\"%UserName%\")");
a.writeline (" strComputer = \".\" : MB = 1024 * 1024");
a.writeline (" Set objWMIService = GetObject(\"winmgmts:{impersonationLevel=impersonate}!\\\\\" & strComputer & \"\\root\\cimv2\")");
a.writeline (" Function window_onLoad");
a.writeline (" GetInfo : iTimerID = window.setInterval( \" GetInfo\" , 300, \"VBScript\")");
a.writeline (" Lb1.InnerHtml = Uname & \"<BR> Process List\"");
a.writeline (" End Function");
a.writeline (" Function GetInfo");
a.writeline (" For i = (objTable.Rows.Length - 1) to 0 Step -1");
a.writeline (" myNewRow = document.all.objTable.deleteRow(i)");
a.writeline (" Next");
a.writeline (" Set objRow = objTableBody.InsertRow() : objRow.Style.fontWeight =\"Bold\"");
a.writeline (" Set objRow = objTable.InsertRow() : objRow.Style.Color =\"Red\"");
a.writeline (" Set objCell = objRow.InsertCell() : objCell.InnerText =\"Process ID\"");
a.writeline (" Set objCell = objRow.InsertCell() : objCell.InnerText =\"Process Name\"");
a.writeline (" Set objCell = objRow.InsertCell() : objCell.InnerText =\"Memory Usage\"");
a.writeline (" Set colProcesses = objWMIService.ExecQuery(\"SELECT * FROM Win32_Process\")");
a.writeline (" For Each strProcess in colProcesses");
a.writeline (" SP_PID = strProcess.ProcessID : SP_Name = strProcess.Name");
a.writeline (" FR_Name = FormatNumber(strProcess.WorkingSetSize,0,,,-1) /1024");
a.writeline (" Txt_Line = Space(5) & SP_PID & space(5) & SP_Name & space(5) & FR_Name");
a.writeline (" Set objRow = objTableBody.InsertRow()");
a.writeline (" Set objCell = objRow.InsertCell()");
a.writeline (" objRow.Style.Color =\"#0000C8\"");
a.writeline (" objRow.Style.fontWeight =\"Bold\" ");
a.writeline (" objCell.InnerText = strProcess.ProcessID");
a.writeline (" Set objCell = objRow.InsertCell() : objCell.InnerText = strProcess.Name");
a.writeline (" Set objCell = objRow.InsertCell()");
a.writeline (" Mem = FormatNumber(strProcess.WorkingSetSize,0,,,-1) / MB");
a.writeline (" Mem = Left(Mem,4) : objCell.InnerText = Mem & \" Mb\"");
a.writeline (" Next");
a.writeline (" End Function");
a.writeline (" Function KillTask");
a.writeline (" Tkill = InputBox( \"Type In The Name Of The Process To Kill\" ,\"Task Kill Process\",,5500,4800)");
a.writeline (" If Tkill = \"\" Then : window.Alert \"User Has cancel Task Kill\" : End If");
a.writeline (" If Tkill <> \"\" Then");
a.writeline (" Set colProcessList = objWMIService.ExecQuery(\"Select * from Win32_Process Where Name = '\" & Tkill & \"'\")");
a.writeline (" For Each objProcess in colProcessList : objProcess.Terminate() : Next");
a.writeline (" End If");
a.writeline (" Exit Function");
a.writeline (" End Function");
a.writeline (" Function HTAEXIT");
a.writeline (" If Fso.FileExists(Sd & \"\\ListProcess.hta\") Then : Fso.DeleteFile(Sd &\"\\ListProcess.hta\") : End If ");
a.writeline (" Window.close");
a.writeline (" Exit Function");
a.writeline (" End Function");
a.writeline (" </SCRIPT></Head>");
a.writeline ("<!-- ================================================ -->");
a.writeline (" <body SCROLL=\"Yes\" CLASS=\"Normal\"><Table WIDTH=\"455\" ALIGN=\"Center\">");
a.writeline (" <TD CLASS=\"BTN2\"><TABLE WIDTH=\"425\" ALIGN=\"Center\">");
a.writeline (" <TD><input TYPE=\"button\" LANGUAGE=\"vbscript\" VALUE=\"Kill Process\" CLASS=\"BTN1\" ONCLICK=\"KillTask\"></TD>");
a.writeline (" <TD> </TD>");
a.writeline (" <TD CLASS=\"BTN2\" WIDTH=\"275\" ALIGN=\"Center\"><SPAN ID=\"Lb1\"></SPAN></TD>");
a.writeline (" <TD> </TD>");
a.writeline (" <TD><input TYPE=\"button\" LANGUAGE=\"vbscript\" VALUE=\"Exit App\" CLASS=\"BTN1\" ONCLICK=\"HTAEXIT\"></TD></Table>");
a.writeline (" <TABLE ID =\"objTable\" CLASS=\"TKT2\" Width=\"425\"><TBODY ID =\"objTableBody\" CLASS=\"TKT2\" Width=\"425\">");
a.writeline (" </TBODY></TD></TABLE>");
a.writeline (" <TD> </TD>");
a.writeline (" <Table ALIGN=\"Center\"><TD>");
a.writeline (" <input TYPE=\"button\" LANGUAGE=\"vbscript\" VALUE=\"Kill Process\" CLASS=\"BTN1\" ONCLICK=\"KillTask\">");
a.writeline (" </TD></Table></Body>");
a.close();
Act.Run(File,1,true);

Edited by gunsmokingman
Link to comment
Share on other sites

I only know a littte about Js Script, I play around with it. The advantage of JS script over VBS script is that it can run on a web page.

The changes

1:\ Added a drop down menu called Windows Tools, this has a TD class that act like a button

that start the JS script, I may add some more stuff to this menu.

2:\ Added some more Computer Information, where the Windows directory is and Windows Serial Number

3:\ Added the Ram WMI stuff you posted

4:\ Starting to clean up the code for the HTA.

SystemReport_V3 with drop menu open, when it close you only see the text Windows Tools

SystemReport_V3.png

When I have all the WMI information completed I will add the to the HTA, what ever else was in your original script.

SystemReport_V3, re edit with changes that Yzöwl pointed out.

Yzöwl these where never in the script <TR> and </TR>

Updated HTA SFX SystemReport_V3

Edited by gunsmokingman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...