Which version did you try? The original did delete shortcuts if they were the same name as a shortcut being created, but the second version doesn't(shouldn't).
As for the deleting of the Drive letter shortcuts I will look into that. I dont keep shortcuts to the drives on my desktop so that issue didn't come up for me.
Also I have attached a new version which recurses only 1 level (easily changed) looking for exe files.
This version does not remove any drive icons or other existing icons from my desktop. Let me know if you experience something different.
; Program Version: 1.3
; Language: English
; Author: belkira
; Script Function:
; Script to create shortcuts on Desktop for exe files on a removable drive
; and then to remove those shortcuts when the removable drive has been removed.
; Launch script on whatever computer(s) you want to have the shortcuts updated on.
; When a new removable drive is inserted, this script will scan for all exe files on the
; removable device, and create shortcuts for them on the users Desktop.
; Once removed the script will cleanup any shortcuts that were created.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
First = 0
DriveGET, USB, List, REMOVABLE
settimer, check, 500
ret := scan4newDrives(USB)
If (First = 0)
; Copy current shortcuts
FileGetShortcut, %A_LoopFileName%, Target
ShortCutTarget = %ShortCutTarget%%Target%\\%A_LoopFileName%`n
;ShortCutName = %ShortCutName%%A_LoopFileName%`n
First = 1
; Scan usb drive for applications
Usb_Folders = %ret%:\
Loop, %Usb_folders%*.exe, 0, 1
StringReplace, dummy, A_LoopFileFullPath, \, \, UseErrorLevel
If (ErrorLevel > 2) ; ex: "C:\folder1\folder2\folder3\file.ext"
continue ; skip files that are 1 or more folders deep
UsbDirList = %UsbDirList%%A_LoopFileFullPath%`n
Sort UsbDirList, UD`n ;Remove duplicate entries, just in case
; create shortcuts
Loop, Parse, UsbDirList, `n
SplitPath, A_LoopField, Name, Dir, Extension, NameNoExt, OutDrive
FileCreateShortcut, %Dir%\%Name%, %A_Desktop%\%NameNoExt%.lnk
CreatedShortcuts = %CreatedShortcuts%%A_Desktop%\%NameNoExt%.lnk`n
; remove shortcuts if drive removed
If CreatedShortcuts >= 1
Loop, Parse, CreatedShortcuts, `n
Loop, Parse, ShortCutTarget, `n
If A_LoopField =
SplitPath, A_LoopField, Name, Old_Target
StringTrimRight, Target, Old_Target, 1
FileCreateShortcut, %Target%, %A_Desktop%\%Name%
DriveGET, NewUSB, List, REMOVABLE
Loop, parse, NewUSB
if InStr(olddrives, a_loopfield)
;found new device!
olddrives := NewUSB ;update
return, % a_loopfield
olddrives := NewUSB ;update
return, 0 ;no new devices found.