How to terminate a process in vbscript

前端 未结 3 2004
余生分开走
余生分开走 2020-12-09 18:47

How can I terminate process using vbscript. PLEASE NOTE, I need to terminate process that runs under windows 64-bit environment as native 64 (not using select * from win_32_

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 19:32

    The Win32_Process class provides access to both 32-bit and 64-bit processes when the script is run from a 64-bit command shell.

    If this is not an option for you, you can try using the taskkill command:

    Dim oShell : Set oShell = CreateObject("WScript.Shell")
    
    ' Launch notepad '
    oShell.Run "notepad"
    WScript.Sleep 3000
    
    ' Kill notepad '
    oShell.Run "taskkill /im notepad.exe", , True
    

提交回复
热议问题