Home
> Uncategorized > start/kill processes with VB.net
start/kill processes with VB.net
a friend was just asking me over MSN messenger how to start and kill processes using VB.net, so here is some info on it:
* to start a process you can just do
Process.Start("test.exe")
or
Dim proc As New ProcessStartInfo()
proc.Filename = "test.exe"
Process.Start(proc)
see
* to kill a process you can do something like (haven’t tried it though):
Dim plist As Process() = Process.GetProcesses()
For Each p As Process in plist
Try
If p.MainModule.ModuleName.ToUpper() ="TEST.EXE" Then p.Kill()
Catch
‘seems listing modules for some processes fails, so better ignore any exceptions here
End Try
Next p
see
Categories: Uncategorized
VB.net
Use the management console and find the Index service then stop and disable it? You can also turn of indexing in the control panel. Talk about doing things the hard way!
unfortunately in my case that silly process wasn\’t responding to this setting (probably was infected with something)
Speaking of malicious processes, it\’s better to freeze them than kill them sometimes. SysInternals (now MS) free ProcessExplorer can do that, by allowing you to pause a process (maybe they break into the process with the debugger, not sure how they implement the pausing/freezing of the process) while you try to remove it. Then you search for files handles it keeps open and remove them so that you can then delete that process DLLs and other files and any registry entries it makes to make it not run again (see http://www.sysinternals.com)
Just changed "GetProcesses()" to "Process.GetProcesses()"
removed import of System.Diagnostics namespace, doesn\’t seem to be needed