Sign in to follow this  
Followers 0
Onepissedpenguin

Getting my USB drive to open AND run some scripts

5 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

yes i had tried

ShellExecute("explorer.exe","\")
but it opens the contents of the drive in a new window - fine, but a little annoying.

I wanted a way of making the drive open in the same explorer window.

Edited by Onepissedpenguin

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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

that worked great, thanks


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

Share this post


Link to post
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
Sign in to follow this  
Followers 0