First option: regedit (type “regedit” in the Win 7 start menu)
Go to key
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer (for current user) or to key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer (for the whole machine – NB: restrictions set here will add up with those set per user), then create or modify DWORD value
NoDriveTypeAutoRun: set it to ff (hexadecimal) to disable autoplay completely (USB key, CD/DVDs, external hard drives, etc).
Second option (a bit more user-friendly IMO): Group Policy (type “edit group policy” in the Win 7 start menu). Note that maybe this is not available in the most basic editions or when you are not logged in from an administrative account. Then browse to
Local computer policy → Computer configuration → Administrative templates → Windows components → Autoplay policy, and configure the stuff in there.
Finally, if all you need is a temporary toggle, you can simply HOLD the shift key while inserting the external media for which you don’t want autoplay to run.
For a more detailed version (too detailed, if you ask me), see Disable USB Drive Autorun – Computer Fix and Resources