Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I increase the size of start run command line to increase the target

Tags:

c#

.net

winforms

I am passing parameters from start-run to my windows application. What I came to know is that you cannot pass more than 259 characters . I have an windows application in C# where I want to pass arguments. Initially I gave as commandline arguments, using the enviorment.getcommandlineargs, which did work successfully. Now the client made a new requirement that instead of going to the command prompt and sending the arguments, he will be sending from start-run line (he will not go to the command prompt). That exe consist of parameters whose length exceeds 259 characters.

How I am supposed to cope up in this scenario.

like image 784
cmrhema Avatar asked Dec 11 '25 06:12

cmrhema


2 Answers

Use an application config file rather than command line arguments if you have that many configurable items.

If necessary you could always accept the config file location as a command-line argument.

like image 137
Paolo Avatar answered Dec 12 '25 20:12

Paolo


The easy win here would be to trim your argument lengths individually. If you are not expecting a user to remember the argument values, you can shorten the keys and values.

e.g. If your app previously took something like myApp.exe myFirstParam=EnableGui mySecondParam=DataHere you can easily shorten this to myApp.exe p1=1 p2=14. These shortened parameters may be added in addition to the longhnad version to preserve the ability to run from a command line with recognised arguments, but will lower the number of characters required for the new parameters.

Of course, it may be that you are not able to shorten the values in your parameters, but shorter keys may help.

There's always the option of calling a .bat / .cmd file with all the parameters specified, too. This would have a similar effect to providing a config xml file, but without the (admittedly trivial) additional coding requirement.

like image 37
ZombieSheep Avatar answered Dec 12 '25 20:12

ZombieSheep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!