Question

I have a script that I found online which runs an .exe on my flash drive whenever I plug it in. However I have a second flash drive which obviously has a different letter to the first one, and I want the same script to attempt to try and find the (same) .exe in both flash drives when I only plug on of them in. Currently the code is this:

$DBT_DEVICEARRIVAL = "0x00008000"
 $WM_DEVICECHANGE = 0x0219
 GUICreate("")
 GUIRegisterMsg($WM_DEVICECHANGE , "MyFunc")
 Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam)
 If $WParam == $DBT_DEVICEARRIVAL Then
Run ("J:\DropboxPortableAHK\DropboxPortableAHK.exe")
 EndIf
 EndFunc
 While 1
 $GuiMsg = GUIGetMsg()
 WEnd
Run ("K:\DropboxPortableAHK\DropboxPortableAHK.exe")
 EndIf
 EndFunc
 While 1
 $GuiMsg = GUIGetMsg()
 WEnd

Now, I'm not gonna lie, I don't actually have a clue what any of this does, with the sole exception of the Run command. I'm a very novice programmer and I only have experience in Python3, so I tried adding a second run command after the first but it didn't work. I tried Googling the problem, but I couldn't find anything that I recognised as similar to my question. If anybody knows how I could get the same script to detect both drives (J and K), that would be greatly appreciated.

Thanks, Tom

Was it helpful?

Solution

To give you a quick and dirty solution: Just double only the first Run(...) line and change the drive letter. Nothing will happen, when the path won't be found... but if both are found, both will be run. And remove all the lines after WEnd. That's just unnecessary copy'n'paste without knowing what you do ;-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top