Can someone make a small VB app for me?

Joined
Jul 19, 2003
Messages
8,037
Reaction score
2
I need a window with a single button that runs this code when clicked. If you could allow the customising of the strProcessToKill variable that would be cool, but not required.

I'm downloading VB Express to see if I can do it, but I figured one of you lot might be able to do it quicker.

Code:
strComputer = "."
strProcessToKill = "game.exe"

Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")

Set colProcess = objWMIService.ExecQuery _
   ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")

count = 0
For Each objProcess in colProcess
   objProcess.Terminate()
   count = count + 1
Next


wscript.echo "Killed " & count & " instances of " & _
   strProcessToKill
 
I think I did it...Here's the code for anyone who gets an annoying crashing game where you can still see your cursor...Change the "game.exe" to the process name, then compile it.

Code:
Public Class Form1

    Private Sub Button1_Click() Handles killDesperados.Click

        Dim strComputer = "."
        Dim strProcessToKill = "game.exe"

        Dim objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")

        Dim colProcess = objWMIService.ExecQuery _
           ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")

        Dim count = 0
        For Each objProcess In colProcess
            objProcess.Terminate()
            count = count + 1
        Next

        MessageBox.Show("Killed " & count & " instances of " & _
   strProcessToKill, "My Application", _
           MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)

    End Sub

End Class
 
doesn't End() or something close the program?

It's been a year or so since i've used VB, sorry
 
Visual Basic is the Devil's language.
 
Visual Basic is the Devil's language.

VB is easy. Of course I only use it with .NET

But here's what's weird... why do we have such a horrible way to display code? Light gray on white? Come on...

Also - why do you need this? Do you have Windows 7? The task manager comes up under pretty much any circumstances.
 
VB is easy. Of course I only use it with .NET

But here's what's weird... why do we have such a horrible way to display code? Light gray on white? Come on...

Also - why do you need this? Do you have Windows 7? The task manager comes up under pretty much any circumstances.

Probably to kill dozens of instances of the program, no fun killing that :p

But for that purpose, I used this before but had to look it up again, you can use a cmd prompt with 'taskkill /im <process name>.exe'
 
I got it to work anyway. It's for Desperados on GOG. http://www.sendspace.com/file/ge7zk1

The game hangs your screen sometimes and the task manager is hidden.

I knew about the batch taskkill, but I needed something with a button so you could just alt-tab then hit enter, instead of typing Y or N.
 
I agree. While VB is a good starting point, you should move to C++ where you can do a lot more.

Hell nah! C# Bitch! Take your foul mouthed language elsewhere, grandpa!

I joke, but really C# > C++. It's not a lower level language, but it's so much nicer. The performance vs productivity trade-off is really where C# shines.

Then again I can't speak since I don't make shit. :( Productivity = 0 :(
 
Well, true. I still do some of my stuff in C# and I have to agree that it is nicer.
 
In the .NET world you can use VB and C# pretty much interchangeably.... you can do a lot of the same things. C# has a little more hardcore stuff going on and is a lot friendlier with WPF/Silverlight. C++ is still used everywhere in the gaming world which is the only reason I need to get back in to it. I think game programming is the thing cool people do. This stupid interface programming I've been doing is stupid.
 
Hit Windows Key + L to switch users and you should regain control of the screen once you log back in.
 
Yeeeeeeep.

UD0hf.jpg
 
Back
Top