Question VBS Scripting - Help Needed

BadThad

Lifer
Feb 22, 2000
12,100
49
91
I need a VBS script to kill two running processes. I can do it in PowerShell, no problems using:

taskkill /f /im CorsTra.exe
taskkill /f /im M95Hid.exe

However, in my google searches (yes, I'm pathetic with code) none of the suggestions worked and I tried a few like this:

Dim oShell : Set oShell = CreateObject("WScript.Shell")​

oShell.Run "taskkill /f /im M95Hid.exe",,True​

Dim oShell : Set oShell = CreateObject("WScript.Shell")​

oShell.Run "taskkill /f /im CorsTra.exe",,True​


What VBS code do I need to accomplish this simple task because the above and nothing else I tried does? They run but the processes never end. Thanks!
 
  • Like
Reactions: Orfosaurio

lantis3

Senior member
Oct 18, 2023
279
56
61
Why not just remove them from startup?


 
  • Like
Reactions: quietdad2

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Why not just remove them from startup?


Because I want them to run at start-up and my PC very rarely gets rebooted. There are reasons I need to do this, I've been a computer enthusiast for 25+ years.
 

lantis3

Senior member
Oct 18, 2023
279
56
61
Last edited:

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Why not just create a powershell script?
That is exactly what I'm trying to do. However, it does not stop the processes - I just want help with the syntax I posted above. As stated, I can open powershell and the commands execute successfully with no problems (the processes stop). However, when I write the code, save it as a .vbs file and run it - it does not stop the processes.

Thanks
 

Ajay

Lifer
Jan 8, 2001
16,094
8,112
136
That is exactly what I'm trying to do. However, it does not stop the processes - I just want help with the syntax I posted above. As stated, I can open powershell and the commands execute successfully with no problems (the processes stop). However, when I write the code, save it as a .vbs file and run it - it does not stop the processes.

Thanks
Sorry, I misunderstood. You want code that'll do what PowerShell does easily, except as a VB script. Good luck, haven't written any VBS in long time.
 
  • Like
Reactions: BadThad

BadThad

Lifer
Feb 22, 2000
12,100
49
91
Sorry, I misunderstood. You want code that'll do what PowerShell does easily, except as a VB script. Good luck, haven't written any VBS in long time.
Exactly, thanks for clearing it up. It's a simple thing really, a lot of people know VB....but they're not here anymore I guess. :(
 

lantis3

Senior member
Oct 18, 2023
279
56
61
What errors are you getting?

When I copy & paste your code into notepad++, it kept complaining invalid characters

When I turned on showing all hidden characters, it showed that ZWSP (zero width space) character was appended at the end of line. I have to remove that ZWSP from the file so it can compile.

The following code worked without error.
Code:
Dim oShell
Set oShell = Wscript.CreateObject("WScript.Shell")
oShell.Run "taskkill /f /im notepad.exe"
Set oShell = Nothing

Also haven't done programming for a long time, by the way.

Can't install Corsair M95 software since I don't have that mouse.
 
  • Like
Reactions: igor_kavinski

TheELF

Diamond Member
Dec 22, 2012
4,027
753
126
That is exactly what I'm trying to do. However, it does not stop the processes - I just want help with the syntax I posted above. As stated, I can open powershell and the commands execute successfully with no problems (the processes stop). However, when I write the code, save it as a .vbs file and run it - it does not stop the processes.

Thanks
You do not need to run this as VBS, save it as a text file rename the extension to .bat and run it as administrator, or just run the vbs as admin, I'm pretty sure the only issue here is the admin/elevated access.
You can only run powershell as admin so it would work inside of that, outside you have to force admin.

I'm talking about these commands.
taskkill /f /im CorsTra.exe
taskkill /f /im M95Hid.exe
 

BadThad

Lifer
Feb 22, 2000
12,100
49
91
You do not need to run this as VBS, save it as a text file rename the extension to .bat and run it as administrator, or just run the vbs as admin, I'm pretty sure the only issue here is the admin/elevated access.
You can only run powershell as admin so it would work inside of that, outside you have to force admin.

I'm talking about these commands.
taskkill /f /im CorsTra.exe
taskkill /f /im M95Hid.exe
YES - that worked! Hallelujah, you are THE MAN, thanks!
 
  • Like
Reactions: igor_kavinski