Mark
Mark

Reputation: 183

How to terminate a process in 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,

Upvotes: 18

Views: 125123

Answers (4)

Shubham Verma
Shubham Verma

Reputation: 9961

Here is the code to exit from the loop:

Function main()
do while (SOME_CONDITION)
    If SOMETHING_1 = 1 Then
        DO_SOMETHIONG()
        Exit Do
    End If
loop
End Function

main()

Upvotes: 0

Eric Moon
Eric Moon

Reputation: 131

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.

Upvotes: 2

Saji Samsaji
Saji Samsaji

Reputation: 41

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.

Upvotes: 4

Helen
Helen

Reputation: 98011

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

Upvotes: 36

Related Questions