Disable autorun in Windows XP

Except for using gpedit.msc to disable the Autorun, here is the other procedure for creating a batch (.BAT) file that creates an AUTORUN.INF folder and disables the autorun feature in Windows.
  • Open Notepad. Click Start>Run, type NOTEPAD, then press Enter.
  • Copy and paste the following text in Notepad: 

 <@echo off :: SET_NO_DRIVE_OTORUN reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoDriveTypeAutoRun /t REG_DWORD /d 0x0ff /f :: GET_DRIVES for /f "tokens=1 delims=:" %%j in ('reg query hklm\system\mounteddevices ^| findstr \DosDevices\') do ( echo %%j >> drives ) :: REMOVE_\DosDevices\_PREFIX for /f "tokens=3 delims=\" %%j in (drives) do ( echo %%j >> drives.txt ) del /q /f drives > nul :: REMOVE_SPACE for /f "tokens=1 delims= " %%j in (drives.txt) do ( echo %%j: >> drives ) del /q /f drives.txt > nul :: CHECK_DRIVE_TYPE for /f %%j in (drives) do ( fsutil fsinfo drivetype %%j | findstr "Fixed " >> fdtype fsutil fsinfo drivetype %%j | findstr "Removable " >> frtype ) del /q /f drives > nul :: GET_FDRIVES for /f "tokens=1* delims= " %%j in (fdtype frtype) do ( echo %%j >> dtype ) del /q /f fdtype > nul del /q /f frtype > nul :: REMOVE_SPACE1 for /f "tokens=1 delims= " %%j in (dtype) do ( echo %%j >> drives ) del /q /f dtype > nul :: DEL_DRIVE_A_FROM_LIST sort drives >> sort type sort | findstr "A" > nul if errorlevel 0 for /f "tokens=1 skip=1" %%j in (sort) do ( echo %%j >> sorted ) del /q /f drives > nul del /q /f sort > nul :: CREATE_OTORUN_FOLDER for /f %%j in (sorted) do ( md %%j\AUTORUN.INF attrib +s +h +r /d /s %%j\AUTORUN.INF ) del /q /f sorted > nul echo Press any key to close this window.. pause > nul>
    • Save the created file on your Desktop as the file DISABLE.BAT.
      • Locate the file on your desktop. Once located, double-click on the file.