You are here

USB Autorun

5 posts / 0 new
Last post
teetwo
Offline
Last seen: 9 years 12 months ago
Joined: 2011-05-30 10:31
USB Autorun

I am working on a script [AHK] to perform various options to overcome the loss due to
Microsoft's upgrade.

I like PortableApps and will have it load on insertion not just show a folder. It does mean disabling Autorun for the usb in question. I have a flash disinfector folder on the usb drive so although the Computer recognizes the drive it does not react. I run this script and have a Action.txt file on the drive that has the commands. Only run at present. It replaces autorun.inf

If anyone wants to try it I will make it available for further suggestions etc

ie to load Portableapps direct. the entry in Action.txt is
Run
StartPortableApps
This is interpreted with the AHK script as an executable.

Anyway I thought I would offer it. I created this as it is in keeping with an application I am developing to replicate Roboform,Ironkey Plus more.

Motosuwa
Offline
Last seen: 11 years 4 months ago
Joined: 2009-11-10 11:18
Screenshot

If you can supply me a screenshot of the script at work, I will test this vigorously on several systems.

You know what, I've been thinking. When life gives you lemons, don't make lemonade. Make life TAKE THE LEMONS BACK! Get mad!! I don't want your lemons; what am I supposed to do with THESE!?

teetwo
Offline
Last seen: 9 years 12 months ago
Joined: 2011-05-30 10:31
Autorun script

This is the script it does not have a screen. This is not the application I wish to use it for. But this is for anyone to try. This script can easily be expanded to perform other tasks. Note This works but needs tidying

The autorun script in AHK is as follows. It can be compiled or run if you have Autohotkey installed.
Watch the word wrap, comments start with ; at the start of a line.
Place a file on the USB 'Action.txt' with contents like so
Run
path to application + yourapp.exe

; This script is to replace the Autorun system
; The concept is to have a script loaded at boot up or started 
;before inserting device. The Action file can be used as well as Autorun.inf
;On boot up the drive list is captured and stored
start:
Tot=0
Oldlength=0
Newlength=0


DriveGet, OrigDrivelist, List
Oldlength := StrLen(OrigDrivelist)


List:=OrigDrivelist, x:=!!x ; init to true
stringSplit, chr, list
while chr%a_index% ; Alternative loop method if theres no auto array
  ascList .= chr%a_index% " " (y:=asc(chr%a_index%)) subStr(x+=y,1,0) "`n"
Oldtotal = %x%

;File total of drive letters ascii value
;FileAppend, %x%, DriveTotal.txt ;might not be needed
; Now gointo loop to check new drive insertion

Loop{
DriveGet, NewDrivelist, List

Newlength := StrLen(NewDrivelist)
if (Newlength >OldLength) {
goto Newdrive
  }

if (OldLength>Newlength) {

    Goto start 
    }    
; Insert Hot Keys here
; Exit program
;Help file display
}


NewDrive:

;We deal with drive insertion
; Total ascii numbers new list

x=0
List:=NewDrivelist, x:=!!x ; init to true
stringSplit, chr, list
while chr%a_index% 
  ascList .= chr%a_index% " " (y:=asc(chr%a_index%)) subStr(x+=y,1,0) "`n"
Newtotal = %x%

Tot .=Newtotal-Oldtotal

D=% Chr(Tot)
msgbox  % Chr(Tot)

SetWorkingDir %D%:\


FileReadLine, OutputVar, action.txt, 1

opt= %OutputVar%


; Now we perform the tasks based on the options
If opt =Run
{
 Goto RunApp
}

ExitApp

RunApp:
FileReadLine, OutputVar, action.txt, 2

Runwait, %OutputVar%

ExitApp

Explanation I have a number of USB's that do many tasks. All I want is for them to start without double clicking the program when the folder view comes up. To stop Windows reacting I used the free program Flash Disinfector you will have to read the explanation on the site.

To autostart PortableApps installed on the drive
run script
The Action.txt file should have this
Run
PortableApps.exe

It seems complicated but I now use it for all my USB Drives.

My Control_IT program is not completed and being beta tested.

I have only tested this script on XP however it should run on Vista and Win7

My next task is to get a usb disk to safe remove itself, Tried programs like UsbEject and others but not always successful. Looking into MS's Devcon anhd it's instructions.
Anyone have an idea I would be pleased to try it

Terry

[Use <pre> tag for blocks of code - mod Chris]

Motosuwa
Offline
Last seen: 11 years 4 months ago
Joined: 2009-11-10 11:18
No AHK

Can you send me the stuff via email? Its *nickname* @ gmail. I'll test it if you can.

You know what, I've been thinking. When life gives you lemons, don't make lemonade. Make life TAKE THE LEMONS BACK! Get mad!! I don't want your lemons; what am I supposed to do with THESE!?

teetwo
Offline
Last seen: 9 years 12 months ago
Joined: 2011-05-30 10:31
I posted it

Copy the script above in notepad. Save it as UsbRun.ahk for want of a better name.
Copy that to a folder and place a shortcut on your desktop

In Notepad create a text file Action.txt with
Run
PortableApps.exe.
Place this on the Usb drive root

Install Autohotkey I will compile the script later as an executable after tidying it and perhaps adding some more options.

Now I used the program Flash Disinfector to stop Windows reacting to that Usb drive.

Now if you run the script it waits for the drive insertion recognizes the drive letter and reads Action.txt which gives the script the command to run PortableApps

I have other projects I am working on but I now have a shortcut to the script in the start folder as it runs a program immediately a drive is inserted with a Action.txt file on it. It then removes itself. To use it again it is necessary to double click the shortcut. I created it to end after the insertion.

I make utilities mainly to help me, some I sell some I use. I am a 68 yr old pensioner that has been programming computers since the 80's. Remember it was not the youth of today that invented them. The I pad only came about due to the invention of a plasma screen many many years ago. Sir Clive Sinclair one of the original inventors of the single board computer(ZX80) also was a innovator of modern computers. I learnt to program on one and have it still today.

If I create the loader as a full program + installer + help file I will create it's own site. You would be one of the first to try the concept.

There is one thing. If it is run and there is no Action.txt file it may complain. click ok and the script will abort. Later it would possibly throw a message say No Action.txt on Drive XX

There are a lot of things to check in a finished application and as you have the script you could adapt it how you like. Goes for all out there. See if your version beats mine eventually. Smile

Autohotkey is free as is Flash Disinfector These sites pay for themselves by donations and advertising. Nothing is really free in this world. Even this site and its apps create revenue. But you knew that.

Some of the apps here are created by brilliant minds much cleverer than mine I am ashamed to say.

This is a great site and PortableApps a great program and concept

There is more than one way to skin that pesky cat though
Terry Hobby Programmer

As an after thought:
I posted the script instead of a link to a exec to give you all something to stretch your minds and also add to. Think of it's potential. The commands can be many, varied and complex. It possibly could be made to set themes, load documents in their programs and make Windows use the abilities it has that most programs never use. Wink

Log in or register to post comments