Jump to content

how to import arguments into command prompt?

ObilvionNizer

Hey guys,

I am in the process of creating an c# application than will allow from the import of arguments into command prompt.

the arguments are hard coded in to the c# application but take information from text boxes to import. Is this possible and if so how?

Main Rig - Case: Corsair 200R   Motherboard: Gigabyte GA-Z270-GAMING-K3  CPU: Intel i5 7600 RAM: Corsair H55 RAM: Corsair Vengeance 16GB 3000MHz SSD: Crucial MX500 1 TB 

HDD: 2TB WD Green  GPU: Gigabyte GTX 1660 Ti 6GB Windforce  PSU: Corsair CX 600W  

HTPC - Case: CiT MTX-007B   Motherboard: Biostar H61MGV3, CPU: Intel i5 2400  RAM: Patriot 4GB 1333MHz SSD: 240GB Toshiba SSD PSU: 180W CIT (Came with case)

Corsair 200R Front Bezel Mod

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, deansmylie1993 said:

 

Can you make example? Because you say importing, so I would understand it as running app with arguments, but import into command line sounds like exporting, so I'm a bit lost there.

Do you mean passing arguments to application by running it with arguments and then access them? Or setup something in application and export those settings as runnable command-line command?

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Mr_KoKa said:

Can you make example? Because you say importing, so I would understand it as running app with arguments, but import into command line sounds like exporting, so I'm a bit lost there.

Do you mean passing arguments to application by running it with arguments and then access them? Or setup something in application and export those settings as runnable command-line command?

my plan for the application is to the arguments coded into the application code then when i click install it extracts information from the 2 text boxes and applies them to the arguments ie say i have the C://users/Dean/Documents/Test.apk in one textbox and 192.168.0.0 in another text box, when i click a button it to run the arguments in the command line by exporting what is in the application. so when i click the button cmd should have the following arguments " adb connect 192.168.1.0" and then "adb install C://users/Dean/Documents/Test.apk".

if that makes sense.

Main Rig - Case: Corsair 200R   Motherboard: Gigabyte GA-Z270-GAMING-K3  CPU: Intel i5 7600 RAM: Corsair H55 RAM: Corsair Vengeance 16GB 3000MHz SSD: Crucial MX500 1 TB 

HDD: 2TB WD Green  GPU: Gigabyte GTX 1660 Ti 6GB Windforce  PSU: Corsair CX 600W  

HTPC - Case: CiT MTX-007B   Motherboard: Biostar H61MGV3, CPU: Intel i5 2400  RAM: Patriot 4GB 1333MHz SSD: 240GB Toshiba SSD PSU: 180W CIT (Came with case)

Corsair 200R Front Bezel Mod

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, deansmylie1993 said:

 

Try this https://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx in C++ I use ShellExecuteEx with SHELLEXECUTEINFO structire, that allows me to pass app name and arguments I want the app to start with, and then I can check if process has ended, here is good example how to start process and wait until end https://msdn.microsoft.com/en-us/library/system.diagnostics.process.exitcode(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1 which match your scenario of running first command, wait for it till end and then run another.

Link to comment
Share on other sites

Link to post
Share on other sites

ShellExecuteEx would work & over at PInvoke.net they'd have a .net example of this, however that other sugguestion of using the process class is the preferred way for .net to run applications (& easier to work with).

You'll need to create a ProcessStartInfo instance & want use the .Arguments property to specify your 2 textbox values into. Pass the populated ProcessStartInfo, into a new Process instance then call Process.Start. If you then ever needed to read back the results from the dos window, take a look then at the ProcessStartInfo.RedirectStandardOutput call together with a new StreamReader's ReadToEnd method.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×