Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to terminate a process in vbscript

Tags:

vbscript

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_Process)

Thanks,

like image 615
Mark Avatar asked Nov 24 '09 14:11

Mark


3 Answers

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
like image 174
Helen Avatar answered Nov 05 '22 14:11

Helen


Just type in the following command: taskkill /f /im (program name) To find out the im of your program open task manager and look at the process while your program is running. After the program has run a process will disappear from the task manager; that is your program.

like image 30
Saji Samsaji Avatar answered Nov 05 '22 15:11

Saji Samsaji


I know I am late to the game LOL, but this is what I did to kill SmartScreen.

  1. Create text file KillSmartScreen.vbs

  2. Edit with Notepad:

    Dim oShell : Set oShell = CreateObject("WScript.Shell")
    
    'Kill smartscreen.exe  aka Windows Defender SmartScreen 
    
    oShell.Run "taskkill /f /im smartscreen.exe"
    
  3. Double click KillSmartScreen.vbs to run.

Works like a champ.

like image 1
Eric Moon Avatar answered Nov 05 '22 15:11

Eric Moon