Close exe from Window Close
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts
Page 1 of 1
When my form loads it runs AltWindowDrag. Which is what I want, but now what I wanna do is when it closes. How can I have it close AltWindowDrag as well?
This is what I'm using for it to run on form load...
This is what I'm using for it to run on form load...
Code: Select all
Process.Start(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
Last edited by mikethedj4 on Sun Jul 22, 2012 4:21 pm, edited 2 times in total.
Haven't been coding in VB for months, but i believe its Process.start("C:/Location of program")
Vikhedgehog wrote:Haven't been coding in VB for months, but i believe its Process.start("C:/Location of program")ok thanks I updated the topic, cause now don't know how to close it lol
Some code I found on google :p
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("notepad")
For Each p As Process In pProcess
p.Kill()
Next
To close notepad
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("notepad")
For Each p As Process In pProcess
p.Kill()
Next
To close notepad
Vikhedgehog wrote:Some code I found on google :pHow would I use AltWindowDrag with that?
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("notepad")
For Each p As Process In pProcess
p.Kill()
Next
To close notepad
Code: Select all
Process.Start(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
I assume you would change notepad with AltWindowDrag so it becomes like this:
Code: Select all
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("AltWindowDrag")
For Each p As Process In pProcess
p.Kill()
Next
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
Codex wrote:I assume you would change notepad with AltWindowDrag so it becomes like this:It's not that easy, it's a portable app, no installer, not in registry.Code: Select allDim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("AltWindowDrag") For Each p As Process In pProcess p.Kill() Next
I tried...
Code: Select all
but got the following error...
Dim pProcess() As Process = System.Diagnostics.Process.GetProcesses(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
You do not have the required permissions to view the files attached to this post.
try this:
Code: Select all
Edit: I use this code for a game where you can start and stop a server!p = Process.GetProcessesByName("Process Name")
If p.Count > 0 Then
'Running
Try
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("Process Name e.g. 'Firefox'")
For Each p As Process In pProcess
p.Kill()
Next
Catch ex As Exception
MessageBox.Show("Error!")
End Try
Else
'Not Running
MessageBox.Show("Exe is not running!")
End If
mikethedj4 wrote:Might sound silly, but try to replace \ with / because it seems to be thinking that you try to connect to a remote computer.Codex wrote:I assume you would change notepad with AltWindowDrag so it becomes like this:It's not that easy, it's a portable app, no installer, not in registry.Code: Select allDim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("AltWindowDrag") For Each p As Process In pProcess p.Kill() Next
I tried...Code: Select allbut got the following error...Dim pProcess() As Process = System.Diagnostics.Process.GetProcesses(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
Edit: Yah i tried it in explorer and it thinks that \\ is a computer, while // is a path.
It doesn't make much sense searching for the process after you have already got the value returned from Process.Start. You can use this:
Code: Select all
Dim proc As Process
Private Sub btnStart_Click(sender As System.Object, e As System.EventArgs) Handles btnStart.Click
proc = Process.Start(Application.StartupPath & "\AltWindowDrag\AltWindowDrag.exe")
End Sub
Private Sub Form1_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If Not proc Is Nothing Then
If Not proc.HasExited Then
proc.Kill()
End If
End If
End Sub
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023