vbscript - How to softly end a process using VBS -


i end process using vbscript. unfortunally found examples in authors describing how killing process.

i ask closing. objprocess.terminate() won't help.

i'm using windows xp sp3 admin rights.

any ideas?

thank you!

you try closemainwindow , close methods on process described on msdn, like:

sub killingmesoftly(processname)      'partly copied http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/processes/         strcomputer = "."     set objwmiservice = getobject("winmgmts:" _         & "{impersonationlevel=impersonate}!\\" & strcomputer & "\root\cimv2")     set colprocesslist = objwmiservice.execquery _         ("select * win32_process name = '" & processname & "'")     each objprocess in colprocesslist         objprocess.closemainwindow         objprocess.close     next  end sub 

this bad answer

update
while searching answer, discovered starting script //t:nn option triggers terminate event on objects:

class foo     sub class_terminate         msgbox "gracefull termination"         ' put own termination code here.             end sub end class  dim bar set bar = new foo   loop ' makes script run forever 

save c:\endless.vbs

running script never trigger termination event because hang in endless loop, if start script timeout will; start script command prompt:
c:\>wscript endless.vbs //t:5

you'll see after 5 seconds messagebox "gracefull termination" appears.

this usefull when want quit script after amount of time , run cleanup if not ended itself. not know if covers solution searching for.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -