Sign in to follow this  
Followers 0
joedoe

Script to Disable A Removable Memory Key

15 posts in this topic

I use a memory key allot (USB Flash Key). Is it possible to write an auto it script that can detect what drive letter and info for where it was run, and then disable that drive, so it can be safely removed? Is there a run command for the safely remove hardware tool?

P.s. I have spent a while searching other peoples posts and have not found anything like this. Please forgive me if this sounds like a stupid Newb repeat lazy post

Thank you

Share this post


Link to post
Share on other sites



Cant you just, pull it out? Oo


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

You want to have a script that automatically ejects the drive when it is run, or do you want the USB key to be able to eject itself after it is inserted and has run your script - sorta like a quick insert, run, eject utility that would be useful to update many PCs?

I recollect a recent thread on using a USB key as a lock and some other threads on ejecting the key by program control. The autorun should be easy enough to do. A bit of a search may unearth some goodies.

Share this post


Link to post
Share on other sites

What I want to be able to do is to run a srcipt stored on the computer, and have it "Safely Remove" The flash key. And no I don't want to just pull it out, I have lost data that way, you souldn't do that oO.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You want to have a script that automatically ejects the drive when it is run, or do you want the USB key to be able to eject itself after it is inserted and has run your script - sorta like a quick insert, run, eject utility that would be useful to update many PCs?

I recollect a recent thread on using a USB key as a lock and some other threads on ejecting the key by program control. The autorun should be easy enough to do. A bit of a search may unearth some goodies.

I took your advise and spent a good deal of my weekend searching, I couldn't find anything like what I wanted. I am writing a program for a network with 200+ computers, and I need to install it on all of them, (Here's the Catch) useing only a flashkey, and no keyboard or mouse acces, they are all in storage with just a power cable, so I need to walk to each one, stick the key in the back, have it autorun, install my app, and then disconect it's self, the disconection is key, because they are not all the same and the only way to know when the file has installed is that the light on the USB key will stop flashing when it has been disconected, any help would be much appreciated.

Edited by joedoe

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I use a memory key allot (USB Flash Key). Is it possible to write an auto it script that can detect what drive letter and info for where it was run, and then disable that drive, so it can be safely removed? Is there a run command for the safely remove hardware tool?

P.s. I have spent a while searching other peoples posts and have not found anything like this. Please forgive me if this sounds like a stupid Newb repeat lazy post

Thank you

http://www.uwe-sieber.de/usbstick_e.html

has

RemoveDrive

or

Ejectmedia

maybe you can script around it.

Edited by djek

Share this post


Link to post
Share on other sites

If all you are doing is running a script on the USB key before removing it, why not take advantage of the shutdown facilities in AutoIT and shut the computer down as the last step in your script. That way you can tell that the script was run as the PC is now powered off (and implicitly the USB key has been 'disconnected')

Share this post


Link to post
Share on other sites

If all you are doing is running a script on the USB key before removing it, why not take advantage of the shutdown facilities in AutoIT and shut the computer down as the last step in your script. That way you can tell that the script was run as the PC is now powered off (and implicitly the USB key has been 'disconnected')

Well I kinda want all the computers to keep running after the app is installed and told to run. Larry's link looks realy promising though. Thanks Larry! :lmao:

Share this post


Link to post
Share on other sites

I know this will definitively appear to be a Newb question, but can someone point me in the direction of a working AutoRun Script that will work on a USB key, I have been able to find many that work from CDs but none that will run a .au3 script when a flash key is inserted.

-Thanks Allot!

Share this post


Link to post
Share on other sites

I know this will definitively appear to be a Newb question, but can someone point me in the direction of a working AutoRun Script that will work on a USB key, I have been able to find many that work from CDs but none that will run a .au3 script when a flash key is inserted.

-Thanks Allot!

Those I have seen needs a watch dog on the computer. But your thinking about somthing like a AutoRun feature on the USB key?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Those I have seen needs a watch dog on the computer. But your thinking about somthing like a AutoRun feature on the USB key?

CODE
[Autorun]

Open=yourapp.exe

Action=Name of your Action

Icon=yourapp.exe,2

Label=YourAppLabel

I don't know if you can autorun an au3 script if the target computer doesn't have AutoIt installed? So just package the script as an exe.

In the 'code' above, just note that paths are relative. So, if your app was a folder deep on the drive, you might have Open=foldername\yourapp.exe

Everything but Open is optional. The icon can be anywhere on the drive and is the first in your exe by default, I think.

Also, I'm pretty sure that you can just name an exe file in the root of a drive autoplay.exe and it will run when the drive is loaded.

Edited by AriD

Share this post


Link to post
Share on other sites

Well I kinda want all the computers to keep running after the app is installed and told to run. Larry's link looks realy promising though. Thanks Larry! :P

Would you please let me know if you come up with something in this regard? I'm new to AutoIt as well and think it has a lot of promise. Would like to use it for this purpose as well, if possible.

Also, I've put some code for your autorun question below. Works the same on a USB drive as on any other drive.

Again, please let me know if there is a solution to the ejecting a USB drive issue.

Share this post


Link to post
Share on other sites

I'm too new at AutoIt do write scripts as easily or as well as most of you out there,

But I did run across this program that has a command-line interface for 'safely removing drives'

ftp://ftp.heise.de/pub/ct/listings/0316-208.zip

Now, if you run this from a command window and type "deveject.exe -?" then you can see that you can eject drives by name or drive letter or deviceID.

So, what about putting this into an AutoIt exe with "fileinstall" so that it extracts deveject.exe to the temporary directory. Then have the autoit script search for the device you want to eject. This could be different drive letter on different computers, so probably make a small bit of logic to find the exact device you're looking for in all circumstances, make sure all the processes from it are done (else you'll get an error when trying to eject it), then pass the drive letter or device name from AutoIt to deveject.

Would this work? I know that deveject is only 44KB in size (20KB if you compress it with UPX).

As I said, I'm still too new at AutoIt to program all this myself. So, if you come up with something, let me know. I could use an app like this.

Thanks,

Ari

Share this post


Link to post
Share on other sites

Ok, I am going to look into these things, I forgot about this project, but I should be able to work on it some in the next week.

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