<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx</link><description>It depends on whom you ask.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56029</link><pubDate>Wed, 10 Dec 2003 20:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56029</guid><dc:creator>Juan Miguel Venturello</dc:creator><description>Thanks for this blog Raymond, this is very interesting. Looking forward to the answers tomorrow, I can imagine what some of them will be ;)
This weekend I went through all your blog archives and learnt many, many things I have always wondered about in my win32 developer career, and a few new tricks.

As many said, this is book material :) Good luck with all and again, thanks,

Juan Miguel Venturello</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56030</link><pubDate>Wed, 10 Dec 2003 22:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56030</guid><dc:creator>Jordan Russell</dc:creator><description>I never knew ShellExecute imposed such a limitation. Very good to know.

Here's an unrelated question that might make for an interesting blog topic:

Why does FILE_ATTRIBUTE_NORMAL exist, and why is it defined as 0x00000080? Why not just use 0 when no special attributes are set?</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56031</link><pubDate>Wed, 10 Dec 2003 23:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56031</guid><dc:creator>Catatonic</dc:creator><description>What is the limit for _spawnv(), where you supply your own argv to the process? I use this in my code because I don't have to worry about quoting or escaping special characters. </description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56032</link><pubDate>Wed, 10 Dec 2003 23:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56032</guid><dc:creator>Catatonic</dc:creator><description>Whoops, forgot to post the answer! The limit for _spawnv is a measly 1024 bytes.</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56033</link><pubDate>Wed, 10 Dec 2003 23:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56033</guid><dc:creator>Anonymous</dc:creator><description>_spawnv eventually calls CreateProcess but there doesn't seem to be any limit checks before it calls it (at least in the CRT for VS6).</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56034</link><pubDate>Wed, 10 Dec 2003 23:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56034</guid><dc:creator>Anonymous</dc:creator><description>The CRT for VS6 doesn't check for that limit at all. Infact, it doesn't even use arg_len in _cenvarg at all.</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56035</link><pubDate>Thu, 11 Dec 2003 01:08:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56035</guid><dc:creator>Raymond Chen</dc:creator><description>For historical completeness: The DOS command line length limit was 127 characters.</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56036</link><pubDate>Thu, 11 Dec 2003 01:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56036</guid><dc:creator>Catatonic</dc:creator><description>Interesting. The MSDN documentation for _spawnv must say 1024 bytes for a reason. Just to be safe I'd better stick to it!</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56037</link><pubDate>Thu, 11 Dec 2003 11:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56037</guid><dc:creator>Mike Dunn</dc:creator><description>To pass &amp;gt; 32K chars, use a memory mapped file. You can pass the name of the MMF object (or a handle value, if you let the 2nd app inherit handles from the first) and the length of the memory block on the command line:
 
# Pass 261004 bytes in the MMF called &amp;quot;MyMMFThingy&amp;quot;
appnumber2.exe /n &amp;quot;MyMMFThingy&amp;quot; /l 261004
 
Then of course you add some sync code so that the MMF stays around for as long as both apps need it to.</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56038</link><pubDate>Thu, 11 Dec 2003 18:18:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56038</guid><dc:creator>Raymond Chen</dc:creator><description>Mike got it basically right. Except that you don't want to pass the length on the command line; somebody could pass a bogus length and cause you to crash. And coming up with a unique name can be tricky (plus giving it a name opens you up to attackers who can grab the shared memory object file and look at or even mess with it before the child looks at it -- this is a data tampering / information disclosure attack; you can prevent this by applying ACLs to your shared memory object). I prefer an anonymous inheritable handle, which avoids the synchronization problem as well.</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56039</link><pubDate>Thu, 11 Dec 2003 18:45:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56039</guid><dc:creator>Mi</dc:creator><description /></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56040</link><pubDate>Thu, 11 Dec 2003 18:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56040</guid><dc:creator>Mike Dunn</dc:creator><description>Both good points, Raymond. This teaches me that I shouldn't write code with security implications at 12:25 AM ;)</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56041</link><pubDate>Fri, 12 Dec 2003 19:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56041</guid><dc:creator>James Curran</dc:creator><description>Raymond,
I love the Code/History notes.  Do you take requests?

One of the bugaboos of Undocumented MSDOS coding was attempting to change the master environment variables block.  (If I recall correctly, by DOS6, there were six different ways to find it -- none of which were guaranteed to work, so you had to try all six, and use the number which came up the most).
Which bring us to the question -- Why did microsoft never provide a nice simple (say, INT 21h) interface to add &amp;amp; remove evars.

</description></item><item><title>RE: What is the command line length limit?</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#56042</link><pubDate>Fri, 12 Dec 2003 20:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:56042</guid><dc:creator>Raymond Chen</dc:creator><description>Because you aren't supposed to change the environment of another process, much less the root environment block. Unix doesn't let you do it either.</description></item><item><title>Commenting on this entry has been closed.</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#210008</link><pubDate>Fri, 06 Aug 2004 17:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:210008</guid><dc:creator>Raymond Chen</dc:creator><description>Commenting closes after two weeks.&lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://weblogs.asp.net/oldnewthing/archive/2004/02/21/77681.aspx"&gt;http://weblogs.asp.net/oldnewthing/archive/2004/02/21/77681.aspx&lt;/a&gt;</description></item><item><title>Dynamic FxCop Dependency List Using MSBuild</title><link>http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx#8623231</link><pubDate>Fri, 20 Jun 2008 00:59:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8623231</guid><dc:creator>Paraesthesia</dc:creator><description>&lt;p&gt;Dynamic FxCop Dependency List Using MSBuild&lt;/p&gt;
</description></item></channel></rss>