473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to kill and restart a .exe file

Expand|Select|Wrap|Line Numbers
  1. Public Function RsReDir() 
  2. 'function to restart dns redirector - working as of 12-11-08'
  3. Dim plist As Process() = Process.GetProcesses() 
  4. 'Get and parse list of processes to plist'
  5. For Each p As Process In plist 
  6. 'parse each entry in plist as p process'
  7. Try
  8. If p.MainModule.ModuleName.ToLower() = "dnsredir.exe" Then
  9. p.Kill()
  10. 'If module name of process matches "dnsredir.exe" then kill p'
  11. Catch
  12. 'seems listing modules for some processes fails, so better ignore any exceptions here
  13. End Try
  14. Next p
  15. ChDir("C:\DNSREDIR\")
  16. 'go to C:\DNSREDIR\'
  17. Shell("dnsredir.exe", 1)
  18. 'run "dnsredir.exe'
  19. Return Nothing
  20. End Function
Hi, i would like to kill and restart dnsredir.exe file but the code doesnt' seem to work any idea why?
Jan 22 '09 #1
1 3998
vekipeki
229 Expert 100+
Hi, that post is really hard to read. Please remove the unnecessary tags, reformat it, and add CODE tags where necessary.

Check this link: Process.Kill Method (System.Diagnostics). Process.Kill works asyncronously, so you cannot expect your process to end immediatelly.

You should use Process.WaitForExit Method (System.Diagnostics) to block the execution of your program until the process has ended (or until your specified time elapses).

Also, if you catch an exception, it usually means that your process didn't end successfully, so you should handle that situation somehow (at least not restart it?).
Jan 22 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: yabba | last post by:
w2k server as webadmin i have occasion to kill a user session and couse them to login again. I have the sessionID saved in a file. is there a way to kill the user session without disturbing...
2
by: Micky | last post by:
Can any one give me some pointers on how to kill a running procedure in DB2? I have a long running procedure called from a Java routine and after I kill the Java routine, the procedure keeps...
16
by: bie2 | last post by:
Hi, Here's what I want to do: 1. Start the application. 2. A SplashScreen running in its own thread is started. 3. I'm checking if the application needs an update. 4. If an update is needed...
6
by: technocrat | last post by:
i have a process thats in roll back state..i ts going on forever..i need to kill it and would like to restart it with some changes.... if not atleast i need to know the status of the rollback to...
1
by: helloitsme | last post by:
Hi! For a certain requirement, I need to kill the current application and restart the same application again. For that, I have the follofing code in the form-closing event of the application - ...
4
by: yxq | last post by:
Hello, I want to kill the Explorer process, after Explorer process has been killed, it will restart automatically immediately. How to disable it restart automatically? for example, in Windows Task...
3
by: spectrumdt | last post by:
Hello. I am running Fedora Linux and KDE, using the Konsole command line. When coding Python, I regularly make a bug causing my program to not terminate. But how do I kill the non-terminating...
2
by: =?Utf-8?B?WVhR?= | last post by:
Hello, In the parent process(A), run update function, and start the update process(B), in B process, kill A, then download and update files, then restart A. I want to know can the B process kill...
0
by: Almund | last post by:
Hi, Since a while back PosgreSQL have started to hang making interaction with it impossible. The process still remains in the taskmanager aswell as another process with the same name (which i guess...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.