Forms :: Run A Command Line Script From Within Winforms Application
Jul 19, 2010
I am writing an application in which a user is doing a file conversion. I have a set of tools that can perform the conversion on the fly via command line, but I'm not entirely sure of how to go about passing the parameters I need to the command line and running them. Can someone point me to the right direction?Would I just create a System.Diagnostics.Process and use that? If so how do I do the line by line command? For instance if I need to issue a cd command to change the directory and then execute a command after that how would I do that?
View 1 Replies
ADVERTISEMENT
Mar 11, 2010
I am trying to send a command to the external command line (cmd.exe) from the Windows form application that I'm writing in VB.NET (using VS2008).
I can only access the external program thru the command line (its not my program) and I must do so from a form app.
I am trying to use the following code. I am able to call a cmd.exe window, but I can't pass the command line my command.
Using mp As New Process
With mp.StartInfo
.FileName = "cmd.exe"
[Code].....
View 8 Replies
Aug 2, 2010
I was playing a game recently and saw that they could use args in the shortcut, and I decided to try to impliment this into my application...so far, I got: (runs this sub on load)
Sub startup_args()
If Environment.GetCommandLineArgs.Contains("+game") Then
Dim path As Array = Environment.GetCommandLineArgs
[code]....
just to see what it returns, but the application crashes. I also tried path.tostring(), but that didn't work. When I did:
If Evnironment.GetCommandLineArgs.Contains("+game") Then
Dim path as string = Environment.GetCommandLineArgs.tostring
MsgBox(path)
[code]....
but that returned the value "SString.Array[]"...
View 7 Replies
May 3, 2011
I have a forms app that contains a few forms. My task is to make it run invisibly when called from the command line with arguments.I have defined a Sub Main in a module and made it the startup item. I have an if/then/else that looks at args.length and if it equals 0 then I load the form and run the app normally. But how do I handle things when args are passed? I still need access to all the functions defined in my main form. Can I load the form invisibly and still "use" it?
View 14 Replies
Mar 11, 2010
How do I get the current line and column numbers in a RichTextBox in a Winforms application?
View 3 Replies
Jun 27, 2010
I am working on an application and I want the user to be able to enter commands into a textbox, and when they press enter, the command is printed in a rich text box, executed, and the output is printed. For instance: the user types move{file1}, {location} into the text box and this happens:
>command: move{file1}, {location}
>$ moving file1 to location
>job completed
How would I write lines to the rtb and execute commands when the enter key is pressed?
This works, partly.
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles command.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
RichTextBox2.Text = Environment.NewLine + command.Text
End If
End Sub
it erases everything in the textbox before adding the line... I would also like to be able to make a database of commands, maybe a .dll or something, so that when the user types in something, it checks that database to see if the command exists, if it does it executes, if not, error.
View 1 Replies
Jan 17, 2010
I am working in VB. I have a fairly long and detailed explanation that I'll avoid posting but what I'm looking to find is quite simple. I'm looking for information how the command line executable LAME.EXE (the Mp3 encoder) returns information to the host program/form.
I am a VB novice and a novice to programming in general and am looking to learn more about as much as I can on the whole but basically I have a Windows form that gathers all the necessary information as a front-end:
The input .wav file path
The output .mp3 file destination
The encode settings (bitrate, frequency, etc)This information is pooled in to a string like this: lame.exe -v -b 112 input.wav output.mp3 or any variant on the settings selected in the GUI which is then in turn used to execute LAME.EXE with the set of parameters in a command line console...That's all well and good and it is quite functional but what I'm looking to do is to 'hide' the console in itself and have the encoder feed back its progress, say as a percentage inside the GUI.
The problem is that it doesn't appear that LAME in itself has this kind of functionality explicitly built in. I know it's possible however, as every single front end in the world has this functionality.I have tried a few ways of doing this with avoiding the issue of not being able to find the functionality within the codec. Perhaps I'm looking in the wrong place entirely or I'm not thinking correctly 'outside the box' as it were.
what I'm looking for is to use a command like this within the script itself: lame(v,b,112,"C:input.wav","c:output.mp3") or even pass the parameters obtained from the GUI a string formatted dynamically on the fly itself.I expect of course that this kind of functionality won't be available anywhere at all, what I'm really looking for as a workaround that reports the actions/progress/console output of the executable back in to the VB program somehow.
View 1 Replies
Jul 8, 2010
OK! I've written my application in all it's GUI glory. I now just want to be able to run it from dos/a command line/batch, with no GUI appearing? So it just runs (& does its batch process).
How can I detect if my application has been initiated from command line/dos?
How do I then not open up the application and show its GUI etc?
View 35 Replies
Jun 7, 2011
is there anyway to get the another application environmenat commandline argument
View 1 Replies
Jun 12, 2010
I want to log lines written from a command line program (unrar.exe) to a multiline textbox.
View 2 Replies
Aug 19, 2009
How can I get a label to display what a command line application is showing. I made it so it can show the final result, but I want it to update live as the app is running.
View 2 Replies
Feb 20, 2009
I'm currently in the middle of a Console Application. I have done everything and it's ready to be handed in. However, I don't want to hand it in like this. I want to build upon it.
One of the ways I'd like to build upon this is with an e-mailing system. I'm find it hard to include the e-mail code in to the project and would like to request assistance. I'm uncomfortable posting the full code on the net as it is for my A-Level Computing and anyone that is doing the same course as me will be able to claim it to be there own.
View 7 Replies
Jun 6, 2012
I have beginner skills using VB (am using the Express edition to learn). I would like to know how to set up a conditional statement in a Windows Form (WF) app that would check if a specific command line has been passed by another separate app that launchesthe Windows Form app using command lines, and if not passed, then the Windows Form app would shut down (exit, close).So far, I can use:
For Each s As String In My.Application.CommandLineArgs
If s <> "xyz" Then
Me.Close()
[code]....
View 14 Replies
Jun 2, 2011
Any way to add command line arguments to my application so that if someone wants to modify the settings they could run myexe.exe /settings and get the settings form of my application.
View 2 Replies
Jan 27, 2010
Is it possible to restart a VB.NET application, but with different command line arguments than it originally had? Here is the challenge. I want to write a single instance application. If the second instance has the same CL args as the first, then the built-in behavior is fine (second instance never opens, e.BringToForeground=True brings 1st instance to foreground, everything is great). But if the second instance has different CL args, then I would like the first instance to close and the second instance to start. However, once you mark a VB.NET app as "single instance only", it appears that you can never get the second instance. I think: OK, fine, I can just restart my first instance from the StartupNextInstance event. But how do I use the new command line arguments from the second instance? The Restart() method does not take CL args that I can see.
View 5 Replies
Mar 15, 2010
Just wondering if there is anyway to read each line of text that is output from a console application?
Basically I want to use PSEXEC through a vb.net GUI application and I would like to be able to read any error codes that may occur from the command line.
View 3 Replies
Nov 16, 2010
I am deploying a VB.net 2010 winforms application, and when I install it on the client's machine, the install process also installs an instance of SQL Server 2005 Express. The application connects to a central SQL database on the server. To install, I am using the "Publish" option in VS 2010. Why does it do that? There should be no need for a local instance of SQL Express. Is there a way to avoid installing SQL 2005 Express (I know it is free, but I would rather not have it installed if possible).
View 1 Replies
Sep 28, 2011
I have a VB.NET application that takes command-line arguments. It works fine when debugging provided I turn off Visual Studio's ClickOnce security setting.The problem occurs when I try to install the application on a computer via ClickOnce and try to run it with arguments. I get a crash when that happens (oh noes!).
There is a workaround for this issue: move the files from the latest version's publish folder to a computer's C: drive and remove the ".deploy" from the .exe. Run the application from the C: drive and it will handle arguments just fine.
View 1 Replies
Sep 19, 2011
is it a bad idea to create separate parts/winforms of the same application (using the same SQL Server DB) in different executable files. For example for a School IS: A Receptionist App, A Teacher App, A Principal App and so on.
View 2 Replies
Nov 17, 2008
Is there any way to add command line arguments to a vb express Windows form application?
View 9 Replies
May 11, 2010
I have a normal windows forms application. A button launches a command line application.I need to insert an argument automatically without the keyboard. Then hide the command line application. I've been trying to figure out how to do this but with little success.I need to build a function that does this but I've never built a function before.Here is what I have but it tells me it may result in a null exception.(Because I'm not doing something quite right.)[code]
View 8 Replies
Sep 5, 2011
I need to implement, Controls Based Security in a Windows Forms Application using VB.NET. I tried google but did not get anything much to work with.
I would like if someone, could suggest some books or tutorials.
View 1 Replies
Mar 27, 2009
My intentions are to add command line switching. I am trying to see if i could run my application in varoius ways i.e.
App.exe -S - Start the application in XX Mode
app.exe -T30 - Start application with 30 second delay
and that kinda switching.
View 7 Replies
Feb 15, 2011
I'm writing a command-line application in .Net. The app itself is fairly simple, but it has to connect synchronously to a web-service, which in turn has to connect to a Oracle database, and those pieces are fond of taking their time.
Is there a straightforward way (without dividing my app exe in two) to continue executing but nonetheless yield execution to the command prompt?
It's Windows, so no "&". Also, I cannot use cmd.exe's "start" cmdlet.
View 4 Replies
Apr 30, 2010
First let me say that I am not sure whether or not this should go in this section or the API section, and if it needs to be moved I apologize. My issue is fairly straight forward, but for some reason I cannot get it to work.
I am trying to send a command to a command line and then submit the command. I have been trying without success to get this to work in v2008 Express and v2010 Express, Here is the code I am trying to us:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String _
[Code].....
View 6 Replies
Feb 24, 2010
I am using the following code to run defrag and to analyze if the C: drive requires defragmentation:
Dim analyze As Process = System.Diagnostics.Process.Start("C:WindowsSystem32defrag.exe", "C: /a /h /u /v")
This process runs through analyzing, runs it in normal mode & prints the progress to the command window.
My problem is that as soon as the process is complete the command window closes. I need it to stay open so that I can read the results.
View 3 Replies
Feb 4, 2011
I am using a CheckedListBox that is populated with Filenames (full path, i.e. C:TestTest.jpg)When I have the files that I want in the CheckedListBox I wish to click a Start Button which will process the list one at a time using an exe program that runs on the Command Line. There are arguments that need to pass to the command line as well as the file location in order for the program to process.I currently have it working but the issue is the loop finishes quickly and it is left up to the CMD.exe to finish the process. What I would like is for the LOOP to wait until each file completes processing before passing the command for the next file in the CheckedListBox.There some reasons I wish for it to work this way.
1) I would like to have a button that can Pause/Restart the Loop.
2) I would like to have a button that can Stop the Loop so the whole process can end.
3) I would like to have the Loop remove each file one by one from the CheckedListBox after it has been processed.
4) I would like to display a Message once all the files have been processed.
5) And if it were possible I would like to report the status either by text or a progress bar showing where it is at in the process.
6) And the ability to add some error handling if possible.
Since the Loop finishes so quickly as it just passes the command to the command line using the & as a seperator it is the command line that is handling the rest of the process. Because of this there is not control over it in the GUI.The code I am using allows the Command Line text to display in the Form so it won't open up a seperate window to run CMD.exe. This is the desired affect as I would like everything to appear to run from within the Form itself.
[Code]...
View 6 Replies
Aug 4, 2009
I'm using Process.Start to start an external command line application and using the StartInfo.Arguments method to send parameters to the application. I imagine I'll need to use a loop... but I can't figure out exactly how yet.I need to send anywhere from 1 - an infinite number of files names to this application. Each file has to be sent one after the other. So once the first one is done, I need to loop back around and past the second one.I can probably use the Directory.GetFiles method to get all of the files, but I don't know how to assign them.
View 7 Replies
May 29, 2012
I am struggling to pass a parameter to a VB.NET application via a Windows scheduled task. It works perfectly in Visual Studio (passing a command line arguement via project properties).If I am calling a VB6 application, then I will supply the following parameters and it works:
Run: c:progra~1TestTest.exe TestParameter Start In: c:progra~1Test However, if I supply the same parameters in VB.NET, the program throws an exception when it tries to create an instance of a class in the Form.Load: System.NullReferenceException cannot create instance of object.
I have also tried the following:Run: c:program filesTestTest.exe TestParameter Start In: "c:program filesTest" This time the status of the scheduled task changes to "cannot start".What is the correct way to specify command line parameters in a scheduled task for a VB.NET program?UPDATE I found the solution on this web page:[URL}.. I am still confused as to why the program would not create an instance of an object when I used the 8 bit paths (i.e. progra~1)
View 1 Replies
Feb 7, 2010
I have several textboxes in a form, and have a button which inserts all the values in a Database and I have to clear the content of all the textboxes and focus to the first one right after pressing the button.Now I can easily do that using the Clear method of each of the textboxes but it takes 10-12 lines of code just for that. Can I do that in one go?
View 2 Replies