![]() |
|
[.NET] VB.NET Run an exe file and close it after 10 seconds - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] VB.NET Run an exe file and close it after 10 seconds (/showthread.php?tid=5637567) |
VB.NET Run an exe file and close it after 10 seconds - Formula 1 - Jun 2, 2017 I want to let it run an exe file that is already exist in the computer, just for 10 seconds then close that exe file. Help anyone? =/ * - eCoLoGy - Jun 2, 2017 (Jun 2, 2017 08:43 AM)uberhacker Wrote: I want to let it run an exe file that is already exist in the computer, just for 10 seconds then close that exe file. A quick solution would be to use a timer. * - AmericanExpress - Jun 2, 2017 The easiest solution would be to just use a timer as suggested above by @eCoLoGy... Within your timer tick event you can just increment a variable, make sure it is set to 1000ms (1 second) and once the variable reaches 10 that means 10 seconds is up so then you can just Application.Exit. * - idb. - Jun 3, 2017 (Jun 2, 2017 09:10 AM)Orka Wrote: My suggestion: I'd say this is the best way provided thus far, but there is no need to use Task.Delay. You can use WaitForExit(10000) instead which returns a boolean. Check that value to determine whether or not Kill needs to be called on the process. * - Lord - Jun 4, 2017 From my understanding you want to run an exe file from your application, correct? I don't see any reason why this wouldn't work. Code Dim KillMe As New System.Diagnostics.Process()* - Formula 1 - Jun 4, 2017 (Jun 4, 2017 02:03 AM)That One Random Wrote: From my understanding you want to run an exe file from your application, correct? Worked perfectly, Thank you! 1 more thing, how can i run it minimized ? The exe program that i ran, i want it to be minimized... * - log dot zip - Jun 4, 2017 (Jun 4, 2017 07:03 AM)uberhacker Wrote: Worked perfectly, Thank you! You went with the worst suggestion out of all of them? Why? * - Formula 1 - Jun 4, 2017 (Jun 4, 2017 07:47 AM)Rabite Wrote: You went with the worst suggestion out of all of them? Why? I just want to run it for few seconds, its simple and works fine.. so why not? * - Ninja - Jun 4, 2017 (Jun 4, 2017 07:49 AM)uberhacker Wrote: I just want to run it for few seconds, its simple and works fine.. so why not? Orkas suggestion was the best. You had to literally just copy paste it. * - Formula 1 - Jun 4, 2017 (Jun 2, 2017 09:10 AM)Orka Wrote: My suggestion: Got some errors bro * - Ninja - Jun 4, 2017 (Jun 4, 2017 10:11 AM)uberhacker Wrote: Got some errors bro How about, this might sound stupid LOL but hear me out, you POST THE ERRORS? * - Washi - Jun 5, 2017 (Jun 4, 2017 07:47 AM)Rabite Wrote: You went with the worst suggestion out of all of them? Why? Care to elaborate why it is the worst? In a single-threaded application, this is perfectly fine. In a multi-threaded application (like GUI applications), if you'd run this on a separate thread, this would cause no problems either. Thread.Sleep is not evil or something, if that's the thing you are looking at. (Jun 3, 2017 12:53 AM)idb. Wrote: ... Good point, but that also implies that you can interrupt the 10 seconds waiting time if the application closes earlier than 10 seconds. Not sure if that is the case in OP's question. Spoiler (Click to View) |