August 16th, 2011, 08:40 PM
Length limit on Run registry entries
I have written an app that writes one or more entries to the HKCU\Software\Microsoft\Windows\CurrentVersion\Run registry key, created based on information enterd by the user. While testing it, I yesterday hit a limit of these registry entries (more accidentally than not).
After some more specific tests I narrowed it down to these registry entries being limited to a maximum length of MAX_PATH (260) including the null terminator. Note that, unlike what one might probably think, that limit doesn't pertain to the path to the executable I'm going to start, but instead to the registry entry in total, i.e. including any command line args I pass to the app to be started by the registry entry. If the limit is exceeded, no error of any kind gets thrown (not even an entry in the Windows event log); the entry is plainly ignored. (To clarify, it's no problem to write the entry to the registry and read it back, it just doesn't get executed.)
Since this app is only aimed at advanced users anyway, I don't think it's a problem to impose a constraint on the data they enter to base the registry entry on, based on the length of the resulting registry entry, and that's how I currently handle it. However, without requiring the user to know how exactly the registry entries are constructed (which IMO is non-trivial even to an advanced user), the error message is somehow vague: It tells the number of excess characters in the resulting registry entry and instructs the user to "shorten some of the values entered to achieve an appropriate registry entry"... Not great, but it's the best I could figure at the time...
However, while I think I can deploy my app the way it currently is, my primary reason for this post is that I didn't find any relevant information on that, let alone authoritative documentation by MS (tried MSDN seach, CG forum search and Google), and I only have XP Pro SP3 to test that here. So, does anyone have more information about that, in particular on whether this restriction has been relieved in Vista or Win7?
Last edited by Eri523; August 17th, 2011 at 05:24 PM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.