Length limit of the Run and RunOnce registry keys

Microsoft has had the registry keys for Run and RunOnce in the registry since the registry was introduced in Windows 95 and Windows NT 4.  But in the 20+ years that those keys have been there (and I’ve used them for a variety of things) I’ve never known that there was a limit on the length of the commands that you could put into those keys.

I found this while working on a client project when I needed to kick off some powershell automatically when the server restarted to get it added to the domain, as well as do a few other things.  But for some reason the key just wasn’t running.

I did a LOT of digging around the Internet and I stumbled across this old Stack Overflow post (from 2012) which in the comments talks about how there’s a limit of 256 characters.  I threw the command in Microsoft word and low and behold my command was 350+ characters long.

The next step was to change the PowerShell script that created the command to put it into a batch file and then setup the RunOnce key to run the batch file instead, and it worked on the next try.

So here it is documented for all the world to see, sometime in the mid 1990s, someone at Microsoft set the length of a command at 256 characters, probably to save memory and because “why would anyone need a command longer than 256 characters”.  And today in 2016 it bit me.

Denny

The post Length limit of the Run and RunOnce registry keys appeared first on SQL Server with Mr. Denny.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Trust DCAC with your data

Your data systems may be treading water today, but are they prepared for the next phase of your business growth?

Share via
Copy link
Powered by Social Snap