Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run
Base variable to command line and then run Base variable to command line and then run
Base variable to command line and then run
Go Back  Xtreme Visual Basic Talk > > > Base variable to command line and then run


Reply
 
Thread Tools Display Modes
  #1  
Old 12-21-2014, 05:33 PM
Jamms Jamms is offline
Newcomer
 
Join Date: Dec 2014
Posts: 3
Default Base variable to command line and then run


Hi guys... I'm pretty new to coding so bear with me!

What I'm looking to do is to have a form with 1 button and 1 text box.

What I need it to do, is take whatever I enter in the text box and use it as argument for a command line program.

Here's what I have so far:

Code:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Process.Start("cmd", "/k livestreamer.exe " & TextBox1.Text & "best")

Ideally, it should run "livestreamer http://www.url.com best"

But I get "livestreamer http://www.url.combest"
No space

If I try to do
Code:
Process.Start("cmd", "/k livestreamer.exe " & TextBox1.Text & " best")
best with a space, it doesn't show up at all when running the program.


I also get this in the debug window in vb2008

Quote:
A first chance exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

Any help is appreciated!
Reply With Quote
  #2  
Old 12-22-2014, 09:09 AM
PlausiblyDamp's Avatar
PlausiblyDampBase variable to command line and then run PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If you are building a command line and have a single parameter that contains a space you will need to enclose the entire parameter in quotes.

One handy tip is to print the generated command line to the debug window and try executing that directly from a command prompt and see what errors or results you get back.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 12-22-2014, 04:14 PM
passel's Avatar
passelBase variable to command line and then run passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,028
Default

To pass command line parameters with Process.Start I think you need to create a ProcessStartInfo object so you can set the command line parameters.
Code:
    Dim cmd As New ProcessStartInfo
    cmd.FileName = "cmd.exe"
    cmd.Arguments = "/k livestreamer " & TextBox1.Text & " base"
    Process.Start(cmd)
Or you could probably just use the Shell command in this case.
Code:
Shell("cmd /k livestreamer " & Textbox1.Text & " base")
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run Base variable to command line and then run
Base variable to command line and then run
Base variable to command line and then run
 
Base variable to command line and then run
Base variable to command line and then run
 
-->