There are two ways to do this. The first way is by editing the registry, the second one uses group policy settings but works only for Vista.
Disable USB Autorun for Windows
- Go to Start > Run
- Type regedit in the box, click OK
- This will open the Registry Editor. Making a backup of the registry is recommended.
- Navigate to the following HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer\NoDriveTypeAutorun
- Right click on NoDriveTypeAutoRun, and then click Modify.
- In the Value Box enter 0xFF to disable USB autorun.
- Click OK and restart the computer.
To disable autorun on only removable drives enter 0x4 in step 6.
For Windows Xp Professional and Vista with group policies, you can find more info at the Microsoft Knowledgebase.