LeonardS Posted September 15, 2017 Share Posted September 15, 2017 I just copied this script from a website: $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 I compiled it to .exe and dragged it to my USB. Now I noticed that when the program isn't running, and I mount the USB in, it doesn't work. But when I run AutoIt <name>.au3 it does work? That means I have to run the program on my PC otherwise the script won't even work? Link to comment Share on other sites More sharing options...
careca Posted September 15, 2017 Share Posted September 15, 2017 (edited) Huh, what? So you have an exe that isn't running, and you want it to work? PS: you need a sleep in the loop, that's pushing the cpu harder than it needs. Edited September 15, 2017 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
LeonardS Posted September 15, 2017 Author Share Posted September 15, 2017 I compiled the .au3 file to an .exe file, I just thought that when I put the USB in the PC it would launch the exe file but it doesn't launch it, but when the script is running on my pc and then put the usb in my pc, it does work... lol Link to comment Share on other sites More sharing options...
LeonardS Posted September 15, 2017 Author Share Posted September 15, 2017 Here is a video to explain: Link to comment Share on other sites More sharing options...
czardas Posted September 16, 2017 Share Posted September 16, 2017 I dunno, but I'm going to hazard a guess at this. No new drive was added when when running the executable from the memory stick, so no message appeared. It's probably something else, but it's worth a guess. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
LeonardS Posted September 16, 2017 Author Share Posted September 16, 2017 I meant: Do I have to run test.au3(autoin logo on my desktop) on my PC to make the test.exe on my USB to work? Because this way, every PC I put my USB in, I first need to run the autoin program first... Thats weird. Link to comment Share on other sites More sharing options...
LeonardS Posted September 16, 2017 Author Share Posted September 16, 2017 I just want a compiled autoin script on my USB, and when I put it in any pc it runs the script. See it as a autorun.inf? Link to comment Share on other sites More sharing options...
czardas Posted September 16, 2017 Share Posted September 16, 2017 AutoIt does not have the capability of automatically running itself as far as I'm aware. Maybe this helps: http://www.allusb.com/usb-explained/usb-autorun operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
LeonardS Posted September 16, 2017 Author Share Posted September 16, 2017 Already tried that, that didn't work :/ I read on another forum that this automatically runs itselfs, but if you say it doesn't have that option, I know now. Thanks Link to comment Share on other sites More sharing options...
czardas Posted September 16, 2017 Share Posted September 16, 2017 (edited) I don't know why it would not work. I also can't verify what you say right now. I suggest you use a very simple program for testing this. Compile the 'hello world' example, from the help file, and see if you can autorun that. I'm sure it should be possible - if not by this method, then by some other method. Is your PC set to allow autorun? Edited September 16, 2017 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
ripdad Posted September 16, 2017 Share Posted September 16, 2017 The script was never meant to run on the inserted device -- only on the PC. When the script is run, it will detect if a usb device is inserted. Which it does. I tested it, and it does what it was designed to do. If you want a script to popup with a msgbox, then make a script and then compile it and use autorun.inf to initiate it. But... Most security conscious users have autorun disabled on their PC. I do. "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward Link to comment Share on other sites More sharing options...
careca Posted September 16, 2017 Share Posted September 16, 2017 (edited) 8 hours ago, LeonardS said: I meant: Do I have to run test.au3(autoin logo on my desktop) on my PC to make the test.exe on my USB to work? Because this way, every PC I put my USB in, I first need to run the autoin program first... Thats weird. You don't have to run the .au3, you can run the compiled exe, but one of them has to be running to detect the usb event. Even if you place it in the autorun, once the usb is in, and the application starts, it will only catch events from there on, not the actual usb that got in, that has the application. As far as running the au3 to make the exe work, no. The exe runs independently. exe and au3 do the same, but the exe runs alone, and the au3 needs another application to run, ex. autoit. Edited September 16, 2017 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
LeonardS Posted September 16, 2017 Author Share Posted September 16, 2017 So confused... I just made a new script with only this code: Run("notepad.exe") I compiled it to .exe and put it on my USB, took the USB out of my pc and then back in, nothing happens... Link to comment Share on other sites More sharing options...
LeonardS Posted September 16, 2017 Author Share Posted September 16, 2017 12 hours ago, czardas said: I don't know why it would not work. I also can't verify what you say right now. I suggest you use a very simple program for testing this. Compile the 'hello world' example, from the help file, and see if you can autorun that. I'm sure it should be possible - if not by this method, then by some other method. Is your PC set to allow autorun? Autorun.inf is disabled for windows 7 and up. And I'm using windows 10. So I guess that won't work Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now