Microsoft disabled autorun. However to run a scan and backup files (defined in file.cmd
), I found this AutoIt script:
$DBT_DEVICEARRIVAL = "0x00008000"
$WM_DEVICECHANGE = 0x0219
GUICreate("")
GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")
Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
If $WParam == $DBT_DEVICEARRIVAL Then
MsgBox(4096, "Info", "My Drive has been Inserted, Backup My Files!")
EndIf
EndFunc
While 1
$GuiMsg = GUIGetMsg()
WEnd
It displays a message box whenever the USB drive, on which the script is, gets plugged in. I compiled and copied it to my USB drive. Soon as I plugged it in, the MsgBox()
appeared.
I replaced:
MsgBox(4096, "Info", "My Drive has been Inserted, Backup My Files!")
with:
Run ("F:\path\to\my\file.cmd")
.
But other computers assign a different drive letter to the USB drive. How can I edit the script so running file.cmd
doesn't require the drive letter F:
assigned? I am completely OK if someone can translate this into Python.