Solved Accepting Command line arguments with win form application

Microsoft Visual studio 2008 professiona...
October 4, 2013 at 12:53:17
Specs: Win7 pro, i7 Core/4ghz
Hi, I have a windows form GUI that changes the computer name and description with button clicks, and sets the network card to DHCP, or configures a static IP address and DNS. This is done by the users selections. I would like for my application to be able to accept command line arguments, which would allow my application to take input from another application that is calling it. I have searched around online for information that would help me to understand the process, but I can't find any thing useful. Can someone please help me figure out this implementation?

See More: Accepting Command line arguments with win form application

Report •

✔ Best Answer
October 8, 2013 at 03:52:45
Again thank you all for your responses: I have figured out my dilemma. with the following code:

Dim args = Environment.GetCommandLineArgs()

If args.Length > 1 Then

TextBox1.Text = args(2) 'this assigns the argument after the .exe file to textbox1 and so on.

TextBox5.Text = args(3)

Next_Button1.PerformClick()

Exit_Button2.PerformClick() ' this accesses the exit button killing the running process.

End If

message edited by bigdee01



#1
October 4, 2013 at 13:54:54
Windows just copies the command line into the process' memory when it loads, and offers the GetCommandLine() function in the Win32 API.

That probably doesn't help you, so I'll answer with this. Depends on the language.

How To Ask Questions The Smart Way


Report •

#2
October 4, 2013 at 16:07:43
The command line is used by a program to accept arguments when it starts. That is really all it is useful for. Windows provides a variety of methods to communicate among processes. Which one is best depends a great deal on the details of the situation. There is much to consider.

Report •

#3
October 4, 2013 at 16:59:19
Old vb32 had COMMAND, as in: A=COMMAND

Report •

Related Solutions

#4
October 5, 2013 at 12:55:23
Thank you all for the responses; My language is VB.Net visual 2010. My GUI has functions and sub routines that are integrated into button clicks; for instance I have a next button, that when clicked, will change the IP, subnet, and DNS primary and secondary. I want to pass an argument to the application from another application that will provide the IP, subnet, and DNS settings. Currently I can provide an argument that will reboot the system based on a shutdown sub routine with the application.

Config.exe /Shutdown

This works; My problem is, I am having trouble passing arguments to any routines within button clicks that take multiple variables. The second problem is when I look in task manager, I can see multiple instances of config.exe running. This means I am not destroying the process correctly.


Report •

#5
October 7, 2013 at 13:03:17
I am having trouble passing arguments to any routines within button clicks that take multiple variables.
Explain this statement.

I can see multiple instances of config.exe running.
Is "config.exe" your application?

How To Ask Questions The Smart Way


Report •

#6
October 8, 2013 at 03:52:45
✔ Best Answer
Again thank you all for your responses: I have figured out my dilemma. with the following code:

Dim args = Environment.GetCommandLineArgs()

If args.Length > 1 Then

TextBox1.Text = args(2) 'this assigns the argument after the .exe file to textbox1 and so on.

TextBox5.Text = args(3)

Next_Button1.PerformClick()

Exit_Button2.PerformClick() ' this accesses the exit button killing the running process.

End If

message edited by bigdee01


Report •

Ask Question