View Single Post
Old 07-02-2009   #2 (permalink)
Ken


 
 

Re: HTA application - trying to use data from text box

Here's my code so far:

<html>
<head>
<meta http-equiv="Content-Script-Type" content="javascript/vbscript">
<title>-=System Tools=-_-=©2009 Ken Kelly=-</title>

<HTA:APPLICATION
APPLICATIONNAME="System Tools by Ken Kelly"
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SINGLEINSTANCE="yes"
NAVIGABLE="yes"
CAPTION="yes"
SCROLL="no"
SYSMENU="yes"
INNERBORDER="no"
BORDER="thin"
BORDERSTYLE="<meta http-equiv=refresh content=300>"
/>


</head>

<SCRIPT Language="VBScript">

Sub Window_onLoad
window.resizeTo 440, 280
End Sub


Sub RunScript1
On Error Resume Next

Set objNetwork = CreateObject("Wscript.Network")
strLocalComputer = objNetwork.ComputerName

strComputer = InputBox _
("Please enter the name of the computer you want to connect to:",
_
"Enter Computer Name", strLocalComputer)

If strComputer = "" Then
Wscript.Quit
End If

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

Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'wmplayer.exe'")

For Each objProcess in colProcessList
objProcess.Terminate()
Next

End Sub

Sub RunScript2
On Error Resume Next

Set objNetwork = CreateObject("Wscript.Network")
strLocalComputer = objNetwork.ComputerName

strComputer = InputBox _
("Please enter the name of the computer you want to connect to:",
_
"Enter Computer Name", strLocalComputer)

If strComputer = "" Then
Wscript.Quit
End If

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colComputer
Wscript.Echo "User Name = " & objComputer.UserName _
& VBNewLine & "Computer Name = " & objComputer.Name
WScript.Echo objComputer.UserName
Next
End Sub


</SCRIPT>
<SCRIPT FOR="defrag" EVENT="onclick" Language="vbscript">
On Error Resume Next

Set objNetwork = CreateObject("Wscript.Network")
strLocalComputer = objNetwork.ComputerName

strComputer = InputBox _
("Please enter the name of the computer you want to connect to:",
_
"Enter Computer Name", strLocalComputer)

If strComputer = "" Then
Wscript.Quit
End If

Set objWMIService = GetObject("winmgmts:\\" _
& strComputer & "\root\cimv2")
Set colVolumes = objWMIService.ExecQuery _
("Select * from Win32_Volume Where Name = 'C:\\'")
For Each objVolume in colVolumes
errResult = objVolume.Defrag()
Next
</SCRIPT>

<SCRIPT FOR="whologgedon" EVENT="onClick" LANGUAGE="vbscript">
dim shell
set shell=createobject("wscript.shell")
shell.run "Scripts\whologgedon.vbs"
set shell=nothing
</SCRIPT>

<body bgcolor="#000000" link="#C0C0C0" vlink="#C0C0C0" alink="#C0C0C0"
text="#C0C0C0">
<center>
<P>
<input type="text" name="MyTextBox" size=40 value="Enter PC Name"><p>
<INPUT TYPE=button STYLE="width: 150px" NAME="whologgedon"
VALUE="Who's logged on?">
&nbsp;
<INPUT TYPE=button STYLE="width: 150px" NAME="defrag" VALUE="Defrag
PC">
<input id=runbutton class="button" type="button" value="Find Serial"
name="run_button" onClick="RunScript1">
</P>
</center>
</body>
</html>
My System SpecsSystem Spec