|
||||||||||
| PC Software Computer software including operating systems, programs, applications, tools and drivers. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Senior Member
Join Date: Apr 2008
Location: Colne, Lancashire
Posts: 7,004
Thanks: 247
Thanked 1,319 Times in 1,211 Posts
|
I am in the process of developing a console application using Visual Basic 2010.
I have all the code in place and the application functions as it should but I want to add a little extra to it. I have managed to get it to launch external applications (notepad, file explorer etc) but I want to set arguments for them. For example, if a process is completed successfully, I want the user to see a message saying something like "Done" or "Failed" if the process wasn't successful. I understand that I need to put the said commands into variables but I am unsure how to do this. Any help would be greatly appreciated, thank you. |
|
|
|
|
|
#2 (permalink) |
|
Senior Member
Join Date: Sep 2007
Posts: 213
Thanks: 17
Thanked 38 Times in 36 Posts
|
I was going to have a go with this, but this page has more than enough information to get you going.
Code:
http://visualbasic.about.com/od/usingvbnet/a/prstrt.htm There should be summat that you can check to see if the process started and completed successfully. As it's a function with overloads you can pass arguments in. If the returned Process is not nothing then it was successful. It'll return nothing if it attaches to an already started process and also you can encapsulate it in a Try/Catch and capture the exceptions. Good luck. PS If you want to post a snippet, I may take a look. |
|
|
|
| The Following User Says Thank You to edds For This Useful Post: | BL4K3Y (21-01-12) |
|
|
#3 (permalink) | |
|
Senior Member
Join Date: Apr 2008
Location: Colne, Lancashire
Posts: 7,004
Thanks: 247
Thanked 1,319 Times in 1,211 Posts
|
Yes, Process.Start is what I am using
.From what I have read, I need to "parse" the command line output (the line(s) I want) in order to create a pass/fail answer. Thanks for the link, I will have a read now. Here is the code that initiates the desired process (the code works fine): Quote:
Last edited by BL4K3Y; 21-01-12 at 07:54 PM. |
|
|
|
|
|
|
#4 (permalink) |
|
Senior Member
Join Date: Sep 2007
Posts: 213
Thanks: 17
Thanked 38 Times in 36 Posts
|
When I parse commandline args I just use Split, I have no knowledge of what yours do. I would assume the process you're starting can accept and handle these args?
|
|
|
|
|
|
#5 (permalink) |
|
Senior Member
Join Date: Apr 2008
Location: Colne, Lancashire
Posts: 7,004
Thanks: 247
Thanked 1,319 Times in 1,211 Posts
|
I guess this is what I am asking, I don't really know lol.
I want to parse the last line of the command (Done!") and use an IF ELSE statement to say true or false based on if it exists in the output. If it helps, I managed to achieve this using batch script by using the FOR /F loop command. |
|
|
|
|
|
#7 (permalink) | |
|
Senior Member
Join Date: Apr 2008
Location: Colne, Lancashire
Posts: 7,004
Thanks: 247
Thanked 1,319 Times in 1,211 Posts
|
Here is a code snippet:
Quote:
I hope the code snippet can help you understand more of what I wish to achieve, thanks for any help .
|
|
|
|
|
|
|
#8 (permalink) |
|
Senior Member
Join Date: Apr 2008
Location: Colne, Lancashire
Posts: 7,004
Thanks: 247
Thanked 1,319 Times in 1,211 Posts
|
Hello again.
I am at the stage where I can get a varied output (success/fail message) when the process is executed but now I want to see the actual process output in the console window in "real time" because I need to be able to see what is happening. From what I have read on the internet, I believe I need to somehow utilise the "OutputDataReceived" event to do this. I have looked at many threads and even looked at some code samples on MSDN but I cannot understand it one bit. Would somebody be kind enough to show me a sample of how this event works so that I have an idea on how to work with it in my application? Thanks in advance for any help or advice .
Last edited by BL4K3Y; 16-02-12 at 05:41 AM. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Advice needed for card share | GJB31 | Satellite Help | 2 | 13-09-11 09:12 PM |
| advice needed | afc4life | Satellite Help | 5 | 08-09-11 09:34 AM |
| Visual Basic Ideas | BL4K3Y | PC Software | 8 | 13-02-11 03:51 PM |
| Beginners advice needed | CC81 | Satellite Help | 2 | 18-09-10 10:04 PM |
| Wireless advice needed | alboking_uk | Broadband | 0 | 30-07-10 08:42 PM |
| LinkBack |
LinkBack URL |
About LinkBacks |
| Bookmark & Share |
Digg this Thread! |
Add Thread to del.icio.us |
Bookmark in Technorati |
Tweet this thread |
