|
-
Oct 3rd, 2004, 07:57 PM
#1
Thread Starter
Banned
kill process on a timer and run a exe ???
ok heres the problem
i need a vb program to kill a process on a timer and then run a exe file after its killed the processes how can this be done
i need it to kill
iinstall.exe
istsvc.exe
and then delete the files inside or the folders
c:\program files\istbar
c:\program files\ISTsvc
say after 2 minitues they have been deleted ,then run a reg file so it cleans the registrys
Last edited by anddos; Oct 3rd, 2004 at 08:56 PM.
-
Oct 4th, 2004, 10:34 AM
#2
Thread Starter
Banned
anyone
-
Oct 4th, 2004, 10:37 AM
#3
Frenzied Member
If you just want it removed, you could use a command prompt... Outside of windows that is...
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 4th, 2004, 11:32 AM
#4
VB Code:
Option Explicit
Private Const PROCESS_TERMINATE As Long = &H1
Private Const PROCESS_QUERY_INFORMATION As Long = 1024
Private Const PROCESS_VM_READ As Long = 16
Private Declare Function CloseHandle Lib "Kernel32.dll" (ByVal Handle As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcId As Long) As Long
Private Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, _
ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hProcess As Long, _
ByVal hModule As Long, _
ByVal ModuleName As String, _
ByVal nSize As Long) As Long
Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, _
ByRef lphModule As Long, _
ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Function KillProcByName(ByVal strProcName As String) As Long
Dim lngProc As Long
Dim lngProcIDs() As Long
Dim lngModules(0) As Long
Dim strModule As String
Dim lngRet As Long
Dim lngCb As Long
Dim lngCbNeeded As Long
Dim lngCbNeeded2 As Long
Dim intLoop As Long
lngCb = 8
lngCbNeeded = 96
Do While lngCb <= lngCbNeeded
lngCb = lngCb * 2
ReDim lngProcIDs(lngCb / 4) As Long
lngRet = EnumProcesses(lngProcIDs(0), lngCb, lngCbNeeded)
Loop
For intLoop = 1 To (lngCbNeeded / 4)
lngProc = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ Or PROCESS_TERMINATE, 0, lngProcIDs(intLoop))
If lngProc <> 0 Then
lngRet = EnumProcessModules(lngProc, lngModules(0), 1, lngCbNeeded2)
If lngRet <> 0 Then
strModule = Space$(256)
GetModuleFileNameExA lngProc, lngModules(0), strModule, Len(strModule)
strModule = Left$(strModule, InStr(1, strModule, vbNullChar) - 1)
If StrComp(Right$(strModule, Len(strProcName)), strProcName, vbTextCompare) = 0 Then
TerminateProcess lngProc, 0
KillProcByName = KillProcByName + 1
End If
End If
End If
CloseHandle lngProc
Next intLoop
End Function
Private Sub Timer1_Timer()
Dim i As Long
On Error Resume Next
KillProcByName "\iinstall.exe"
KillProcByName "\istsvc.exe"
With File1
.Path = "c:\program files\istbar"
.Refresh
For i = 0 To .ListCount - 1
Kill .List(i)
Next i
End With
With File1
.Path = "c:\program files\ISTsvc"
.Refresh
For i = 0 To .ListCount - 1
Kill .List(i)
Next i
End With
On Error GoTo 0
End Sub
Last edited by Jmacp; Oct 4th, 2004 at 11:35 AM.
-
Oct 4th, 2004, 11:44 AM
#5
Thread Starter
Banned
thanks alot my friend i will give this a try 
its saying file1 compile error
With File1
varible not defined
Last edited by anddos; Oct 4th, 2004 at 11:48 AM.
-
Oct 4th, 2004, 11:52 AM
#6
You need to add a filebox control. Looks like a letter icon on the toolbox.
-
Oct 4th, 2004, 12:01 PM
#7
Thread Starter
Banned
nice one m8 , it compiled nicely :P
i will let you know how the program goes
thanks again
-
Oct 4th, 2004, 12:08 PM
#8
Thread Starter
Banned
when i click on the exe i made is it suppose to kill the process's straight away or do i have to wait then it kills the process , dont think its killed them 
do i have to put anything in the filelist box i added as well
also is it suppose to delete the folder
C:\Program Files\ISTsvc
and
C:\Program Files\ISTbar
or just the files inside it
ok to clarify this process dosent get killed
istsvc.exe
and it cant be deleted till its been killed :/
Last edited by anddos; Oct 4th, 2004 at 12:20 PM.
-
Oct 4th, 2004, 12:45 PM
#9
did you set the timer interval in properties. Set it to 1 or so.
-
Oct 4th, 2004, 02:30 PM
#10
Actually you'll need to change that to,
VB Code:
Private Sub Timer1_Timer()
Dim i As Long
On Error Resume Next
KillProcByName "\iinstall.exe"
KillProcByName "\istsvc.exe"
With File1
.Path = "c:\program files\istbar"
.Refresh
For i = 0 To .ListCount - 1
Kill "c:\program files\istbar\" & .List(i)
Next i
End With
With File1
.Path = "c:\program files\ISTsvc"
.Refresh
For i = 0 To .ListCount - 1
Kill "c:\program files\istbar\" &.List(i)
Next i
End With
On Error GoTo 0
End Sub
-
Oct 9th, 2004, 03:15 PM
#11
Thread Starter
Banned
did you set the timer interval in properties. Set it to 1 or so.
all i did was paste the code that u said with the added new code u said for the timer part , i dont know where abouts to add 1 or 0 for the interval
it looks like this
Option Explicit
Private Const PROCESS_TERMINATE As Long = &H1
Private Const PROCESS_QUERY_INFORMATION As Long = 1024
Private Const PROCESS_VM_READ As Long = 16
Private Declare Function CloseHandle Lib "Kernel32.dll" (ByVal Handle As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcId As Long) As Long
Private Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, _
ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hProcess As Long, _
ByVal hModule As Long, _
ByVal ModuleName As String, _
ByVal nSize As Long) As Long
Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, _
ByRef lphModule As Long, _
ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Function KillProcByName(ByVal strProcName As String) As Long
Dim lngProc As Long
Dim lngProcIDs() As Long
Dim lngModules(0) As Long
Dim strModule As String
Dim lngRet As Long
Dim lngCb As Long
Dim lngCbNeeded As Long
Dim lngCbNeeded2 As Long
Dim intLoop As Long
lngCb = 8
lngCbNeeded = 96
Do While lngCb <= lngCbNeeded
lngCb = lngCb * 2
ReDim lngProcIDs(lngCb / 4) As Long
lngRet = EnumProcesses(lngProcIDs(0), lngCb, lngCbNeeded)
Loop
For intLoop = 1 To (lngCbNeeded / 4)
lngProc = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ Or PROCESS_TERMINATE, 0, lngProcIDs(intLoop))
If lngProc <> 0 Then
lngRet = EnumProcessModules(lngProc, lngModules(0), 1, lngCbNeeded2)
If lngRet <> 0 Then
strModule = Space$(256)
GetModuleFileNameExA lngProc, lngModules(0), strModule, Len(strModule)
strModule = Left$(strModule, InStr(1, strModule, vbNullChar) - 1)
If StrComp(Right$(strModule, Len(strProcName)), strProcName, vbTextCompare) = 0 Then
TerminateProcess lngProc, 0
KillProcByName = KillProcByName + 1
End If
End If
End If
CloseHandle lngProc
Next intLoop
End Function
Private Sub Form_Load()
End Sub
Private Sub Timer1_Timer()
Dim i As Long
On Error Resume Next
KillProcByName "\iinstall.exe"
KillProcByName "\istsvc.exe"
With File1
.Path = "c:\program files\istbar"
.Refresh
For i = 0 To .ListCount - 1
Kill "c:\program files\istbar\" & .List(i)
Next i
End With
With File1
.Path = "c:\program files\ISTsvc"
.Refresh
For i = 0 To .ListCount - 1
Kill "c:\program files\istbar\" & .List(i)
Next i
End With
On Error GoTo 0
End Sub
-
Oct 9th, 2004, 03:35 PM
#12
Thread Starter
Banned
i just need to make the compiled exe kill its self
say after 30 seconds of killing processes and deleting
anyone know how to
Last edited by anddos; Oct 9th, 2004 at 04:38 PM.
-
Oct 9th, 2004, 05:38 PM
#13
Thread Starter
Banned
anyone
-
Oct 25th, 2004, 02:52 AM
#14
Thread Starter
Banned
still stuck with this project
ok anyone out there , i still need help witht his program
its not killing the process istsvc.exe ...
also i want the program to kill it self when its done killing the 2 exe's
anyone know
so far the code looks like this
Option Explicit
Private Const PROCESS_TERMINATE As Long = &H1
Private Const PROCESS_QUERY_INFORMATION As Long = 1024
Private Const PROCESS_VM_READ As Long = 16
Private Declare Function CloseHandle Lib "Kernel32.dll" (ByVal Handle As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32.dll" (ByVal dwDesiredAccessas As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcId As Long) As Long
Private Declare Function EnumProcesses Lib "psapi.dll" (ByRef lpidProcess As Long, _
ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Private Declare Function GetModuleFileNameExA Lib "psapi.dll" (ByVal hProcess As Long, _
ByVal hModule As Long, _
ByVal ModuleName As String, _
ByVal nSize As Long) As Long
Private Declare Function EnumProcessModules Lib "psapi.dll" (ByVal hProcess As Long, _
ByRef lphModule As Long, _
ByVal cb As Long, _
ByRef cbNeeded As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Private Function KillProcByName(ByVal strProcName As String) As Long
Dim lngProc As Long
Dim lngProcIDs() As Long
Dim lngModules(0) As Long
Dim strModule As String
Dim lngRet As Long
Dim lngCb As Long
Dim lngCbNeeded As Long
Dim lngCbNeeded2 As Long
Dim intLoop As Long
lngCb = 8
lngCbNeeded = 96
Do While lngCb <= lngCbNeeded
lngCb = lngCb * 2
ReDim lngProcIDs(lngCb / 4) As Long
lngRet = EnumProcesses(lngProcIDs(0), lngCb, lngCbNeeded)
Loop
For intLoop = 1 To (lngCbNeeded / 4)
lngProc = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ Or PROCESS_TERMINATE, 0, lngProcIDs(intLoop))
If lngProc <> 0 Then
lngRet = EnumProcessModules(lngProc, lngModules(0), 1, lngCbNeeded2)
If lngRet <> 0 Then
strModule = Space$(256)
GetModuleFileNameExA lngProc, lngModules(0), strModule, Len(strModule)
strModule = Left$(strModule, InStr(1, strModule, vbNullChar) - 1)
If StrComp(Right$(strModule, Len(strProcName)), strProcName, vbTextCompare) = 0 Then
TerminateProcess lngProc, 0
KillProcByName = KillProcByName + 1
End If
End If
End If
CloseHandle lngProc
Next intLoop
End Function
Private Sub Timer1_Timer()
Dim i As Long
On Error Resume Next
KillProcByName "\iinstall.exe"
KillProcByName "\istsvc.exe"
With File1
.Path = "c:\program files\istbar"
.Refresh
For i = 0 To .ListCount - 1
Kill "c:\program files\istbar\" & .List(i)
Next i
End With
With File1
.Path = "c:\program files\ISTsvc"
.Refresh
For i = 0 To .ListCount - 1
Kill "c:\program files\istbar\" &.List(i)
Next i
End With
On Error GoTo 0
End Sub
Last edited by anddos; Oct 25th, 2004 at 02:57 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|