Re-4: using an ActiveX (twiz32.ocx) from runrev by vbs
Ken Ray
kray at sonsothunder.com
Fri Sep 26 11:20:20 EDT 2008
> In the case the mshta.exe does not close (a problem in ms windows documented
> in the ms kb) I use the following vbs in field 1 and run it from runrev. This
> works and closes any process "mshta.exe".
>
> on mouseUp
> put field 1 into auftrag; do auftrag as VBScript; put the result
> end mouseUp
>
>
> set wmi = GetObject("winmgmts:")
> wql = "select * from win32_process"
> set ergebnis = wmi.ExecQuery(wql)
> for each objekt in ergebnis
> liste = liste & objekt.name & " Prozess-ID: " & objekt.processID & vbCr
> next
>
> wql = "select * from win32_process where name='mshta.exe'"
> set ergebnis = wmi.ExecQuery(wql)
> for each mshta in ergebnis
> mshta.Terminate 0
> next
Yes, I do something similar in a more generic "kill process" handler of mine
(watch word wraps):
on stsKillProcess pProcNameOrID
put the VBS_KillProcess of this stack into tScript
if isNumber(pProcNameOrID) then
replace "<<PROCATTRIB>>" with "Process.ProcessID" in tScript
replace "<<PROCVALUE>>" with pProcNameOrID in tScript
else
replace "<<PROCATTRIB>>" with "Process.Caption" in tScript
replace "<<PROCVALUE>>" with (quote & toLower(pProcNameOrID) & quote)
in tScript
end if
put stsDoScript(tScript,"VBS") <> "" into tResult
-- I have a wrapper around "do script" that does
-- some add'l error checking, etc.)
if tResult is not empty then answer tResult
end stsKillProcess
--- This is the VBS_KillProcess custom property contents:
Set ProcessSet =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select *
from Win32_Process")
tResult = ""
For each Process in ProcessSet
If Process.ExecutablePath <> "" Then
If LCase(<<PROCATTRIB>>)=<<PROCVALUE>> Then
Process.Terminate (Process.ProcessID)
Else
tResult="STSError: Process not found."
End If
End If
Next
WScript.Echo tResult
------------------
Never thought of using HTAs though...
:-)
Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode
mailing list