Register and join over 40,000 other developers!
Recent Topics
-
The Game You Are Waiting For?
WendellHarper - Dec 06 2020 01:21 PM
-
Quora and Reddit Backlinks
WendellHarper - Dec 06 2020 01:14 PM
-
Delete account
pindo - Jul 23 2020 01:33 AM
-
Print specific values from dictionary with a specific key name
Siten0308 - Jun 20 2019 01:43 PM
-
Learn algorithms and programming concepts
johnnylo - Apr 23 2019 07:49 AM
Recent Blog Entries
Recent Status Updates
Popular Tags
- networking
- Managed C++
- stream
- console
- database
- authentication
- Visual Basic 4 / 5 / 6
- session
- Connection
- asp.net
- import
- syntax
- hardware
- html5
- array
- mysql
- java
- php
- c++
- string
- C#
- html
- loop
- timer
- jquery
- ajax
- javascript
- programming
- android
- css
- assembly
- c
- form
- vb.net
- xml
- linked list
- login
- encryption
- pseudocode
- calculator
- sql
- python
- setup
- help
- game
- combobox
- binary
- hello world
- grid
- innerHTML

18 replies to this topic
#1
Posted 29 September 2012 - 04:44 AM
Can anyone help me to pass a command to console for the following file output operation:
c:\>myApp.exe -o outputfile.txt inputfile.txt
I would like to use button click event
c:\>myApp.exe -o outputfile.txt inputfile.txt
I would like to use button click event
#2
Posted 29 September 2012 - 04:55 AM
do you want your program to accept those parameters and perform, or what? where does the button click event come in?
I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.
#3
Posted 29 September 2012 - 05:08 AM
Orjan, thanks. In fact, I have a windows form with a command button. Under the command button event, I try to call my a dos application that helps me convert file1 to file2.
I give the file names of the input and output files as String
It is like:
Command_click (..)
Dim fileOut as String
Dim fileIn as String
Console myApp.exe -o fileOut fileIn
'fileIn is converted to fileOut using my doss application myApp.exe
If I do it "manually", I have to open console, then change to the application directory and use the command I showed above. Instead, I would like to do it with a command button without my manual intervention to the windows console. I am suing VS 2008
I give the file names of the input and output files as String
It is like:
Command_click (..)
Dim fileOut as String
Dim fileIn as String
Console myApp.exe -o fileOut fileIn
'fileIn is converted to fileOut using my doss application myApp.exe
If I do it "manually", I have to open console, then change to the application directory and use the command I showed above. Instead, I would like to do it with a command button without my manual intervention to the windows console. I am suing VS 2008
#4
Posted 29 September 2012 - 06:00 AM
You can do that using Process.Start method. See the example at the bottom of that link.
#5
Posted 29 September 2012 - 07:15 AM
CC Devotee, thanks for the link. I tired to adapt the code as follows
Process.Start("C:\Windows\system32\cmd.exe", "C:\myDosApp.exe -o Output.txt Input.txt")
Windows console pops up but didn't take the argument "C:\myDosApp.exe -o Output.txt Input.txt". Instead, it opens up with the directory path of VS debug.
I would like to make clear that 'myDosApp.exe' is an external DOS application that reads Input.txt and creates Output.txt.
Process.Start("C:\Windows\system32\cmd.exe", "C:\myDosApp.exe -o Output.txt Input.txt")
Windows console pops up but didn't take the argument "C:\myDosApp.exe -o Output.txt Input.txt". Instead, it opens up with the directory path of VS debug.
I would like to make clear that 'myDosApp.exe' is an external DOS application that reads Input.txt and creates Output.txt.
#6
Posted 29 September 2012 - 07:20 AM
Well, I understand that the program to which you are trying to lunch with arguments is an external program.
However, you don't need to start cmd.exe to lunch with arguments but you can start your external program explicitly, e.g. --
However, you don't need to start cmd.exe to lunch with arguments but you can start your external program explicitly, e.g. --
Process.Start("C:\\myDosApp.exe", " -o Output.txt Input.txt").
#7
Posted 29 September 2012 - 07:54 AM
With that, myDosApp.exe tried to open with Windows security alert. I authorized to run. But nothing has happend, no output file is created.
#8
Posted 29 September 2012 - 08:05 AM
You mean you don't want to provide arguments to your program (myDosApp.exe)? Rather, program will read input from the input.txt file and write outputs to output.txt? I mean input.txt file will be the input-stream for your dos program and output.txt will be the output-string?With that, myDosApp.exe tried to open with Windows security alert. I authorized to run. But nothing has happend, no output file is created.
#9
Posted 29 September 2012 - 08:14 AM
You mean you don't want to provide arguments to your program (myDosApp.exe)? Rather, program will read input from the input.txt file and write outputs to output.txt? I mean input.txt file will be the input-stream for your dos program and output.txt will be the output-string?
Kernelcoder, thank you so much.
I would like to give argument to myDosApp.exe indeed. What you have showed me has worked but if I do some manipulation.
In fact, the process argument was pointing to the VB debug path to find myDosApp.exe and the associated input file.
However, when I put the two files (MyDosApp.exe and Input.txt) to the Debug path of my VB test program (where I am testing this process stuff), I see the output.txt is created.
I couldn't make VB test search from c:\MyDosApp.exe and c:\Input.txt to create c:\Output.txt . My VB project is in a differnt path
Edited by jurru, 29 September 2012 - 08:20 AM.
#10
Posted 29 September 2012 - 08:20 AM
The codeHowever, when I put the two files (MyDosApp.exe and Input.txt) to the Debug path of my VB test program (where I am testing this process stuff), I see the output.txt is created.
Process.Start("C:\\myDosApp.exe", " -o Output.txt Input.txt")reads the input file from c:\\input.txt and writes output to c:\\Output.txt.
However, in your case, what about trying like
Process.Start("C:\\myDosApp.exe", " -o C:\\Output.txt C:\\Input.txt")?
#11
Posted 29 September 2012 - 08:52 AM
Kernelcoder, yes the second one has worked. One minor finishing. Is it possible to override security warnings to execute the external application? I mean, to make the process operation silent without user's interaction?
#12
Posted 29 September 2012 - 09:02 AM
I'm not sure about that but just a shot -- can you try running visual studio (if you run the program from within VS) or the winform program itself in administrator mode?Kernelcoder, yes the second one has worked. One minor finishing. Is it possible to override security warnings to execute the external application? I mean, to make the process operation silent without user's interaction?
Also tagged with one or more of these keywords: vb.net, pass command to console
Tutorial Forums →
Visual Basic Tutorials →
Visual Basic .NET Tutorial - How to add google maps in a VB programme Part 2/2 - codecall.netStarted by Cobus, 09 Feb 2016 ![]() |
|
![]() |
||
Language Forums →
Visual Basic →
Find & Replace in MenuStripStarted by Gooer, 21 Dec 2015 ![]() |
|
![]() |
||
Language Forums →
Visual Basic →
Program to give sum of all odd and even digitsStarted by Gooer, 09 Dec 2015 ![]() |
|
![]() |
||
Language Forums →
Visual Basic →
DSP (Digital Signal Processing) with VB.NetStarted by LoneRanger, 19 Aug 2015 ![]() |
|
![]() |
||
Language Forums →
Visual Basic →
I want to learn Visual Basic .Net 2013Started by Raja2921, 28 Jul 2015 ![]() |
|
![]() |
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download