开发者

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

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 exceed开发者_如何学Pythons 259 characters.

How I am supposed to cope up in this scenario.


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.


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.


Is your application always started manually? Then a solution probably may be to convert it to a WinForms application and show the user a dialog where he can enter the parameters. If your program is started sometimes manually, sometimes programmatically, then the best solution may be to support both: a parameter file when there is a command line parameter providing the file, and a dialog when there is none.

By the way, your user will run already into problems when trying to enter more than 259 characters into the Start-Run-Box, it does not accept more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜