Jump to content

Getting my USB drive to open AND run some scripts


Recommended Posts

Hi I have been trying this for ages.

My USB drive has autorun.inf on it which contains:

CODE
[autorun]

label=Aaron's Memory Stick.

shell\runner = Open etc.

shell\runner\command = run.exe

shell=runner

which means that when I double click on the drive in my computer, it starts run.exe instead of opening the drive to view the files.

What I want is for it to do BOTH.

Right now the first line of my script run.exe contains

Send("{ALT}fo")
; when you double-click on the drive in My Computer, opens the drive by going File > Open.

and this gets around the problem, but is very messy and I don't like it. Is there another way of performing the same action? For instance, how do i find out what command windows executes when I click "File > Open"?

One major problem I have with this is that if you double click on run.exe directly it loops.

Eagles may soar, but weasels don't get sucked into jet engines.

Link to comment
Share on other sites

ShellExecute?

Something like:

ShellExecute("explorer.exe")

EDIT: After reading your post again I get the feeling I might have misunderstood what you want?

Edited by Uten
Link to comment
Share on other sites

If you want it to open in the same window you will have to identify the window.. I dont know if its a script only for you, if so use the

;Change "Denne Computer" to whatever its named at your place (My Computer)
$MyComputer = "Denne computer"
$Dir = StringLeft(@AutoItExe, 2)
$handle = WinGetHandle($MyComputer)
If @error Then
    ShellExecute("explorer.exe",$Dir)
Else
    ControlSetText($handle, "", "Edit1", $Dir)
    ControlFocus($handle, "", "Edit1")
    ControlSend($handle, "", "Edit1", "{ENTER}")
EndIf

You might be able to do it via com objects, though i never tried

Edited by Shevilie

Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...