Run Command Prompt When You Click on Your Flash Drive

by locofocos in Circuits > USB

69035 Views, 28 Favorites, 0 Comments

Run Command Prompt When You Click on Your Flash Drive

final.gif
pic5.bmp
What I'll show you how to do today is to make a message open up when you click on your jump drive from My Computer in windows. You will learn to create (or modify) an autorun.inf in the root of your jump drive and create a batch file to be run when you open your jump drive. I will also show you how to display a message when that batch file opens, and optionally add a command prompt to the end that looks like an innocent blinking underscore. Basically, from here, you can do almost anything on a computer that you can't do because of a limited account.

For rather tech suavey people, step 6 is a short version of the whole instructable.

For rather un-tech suavey people, step 7 includes everything you need, plus a simple file
to install it to your jump drive.

Gather Supplies

SanDisk_image1.gif
Get a working jump drive, any size. I'll be using an 8 gig Verbatim jump drive, but really you could do this with a 50 kilobyte jump drive. You will need to be running windows to use it, but any OS can make it. Open up notepad or your OS equivalent. In windows, go to Start-All Programs-Accessories-Notepad .

Also, it might help to have Folder Options under Control Panel set to show hidden files and folders.


Create the Batch File

pic1.bmp
Paste the code below into notepad.

@ECHO OFF
echo Help! I've been lost. I'm sure my owner would love to get me back.
echo
set /P theuserinput=""
%theuserinput%
pause

Go to File and save the file. Save it to the root of your jump drive. Select to save it as type "All Files" and for the filename, type in "lost.bat". This should save it as a batch file. If it shows up as .txt, disable the option of hiding known file extensions under Folder Options in Control Panel. Then it would show up as "lost.bat.txt" (YOU DONT WANT IT LIKE THAT). The icon should be a yellow gear, not a piece of paper. The full name should be lost.bat.

You can choose to edit lost.bat. I have added more lines that display my address, name, phone number, etc so If my jump drive is lost hopefully somebody will return it, of course after also telling them about a cash reward. Just start the line with the word "echo" and then type what you want to display on that line.

Create Autorun.inf

pic4.bmp
Now, open a new document in notepad. Paste this into it.

[autorun]
icon=slax.ico
label=JUMPY
shell\lost=Help! I'm lost!
shell\lost\command=lost.bat
shell=lost

Change the part where it says JUMPY to whatever you want the drive name to be.. Save this file in the root of the jump drive. As you did with lost.bat, set the "Save as type" as all files. Set the file name to "autorun.inf". Go to the root of the jump drive in windows. The file autorun.inf should have an icon as a piece of paper with a yellow gear on it.

Optional- Make the Files Hidden

pic4.bmp
You may want to make each of the files hidden. Most computers won't display hidden files, so if some non-tech-suavey deletes all the files off your jump drive, they still see your message, so somebody is bound to see it and eventually you might get it back if it gets lost. Right click autorun.inf and select properties. Check the mark for Hidden next to attributes. If you haven't disabled the function to not show hidden files and folder, then it appears to disappear. Do the same for lost.bat.

Or you can just go to command prompt and do the following commands (my jump drive is drive L)

L:
ATTRIB autorun.inf +H
ATTRIB lost.bat +H
exit

Both of the above methods do the same thing.

Closings

pic1.bmp
pic3.bmp
That's pretty much it. Close everything out and replug your jump drive. Go to My Computer and try to open your jump drive. The message should show up and after that let you type something in. Anything you type in is like you typed it into command prompt. You can do CMD to get a normal command prompt in the same window. If you don't know much about command prompt, there are guides out here that can show you how to do lots of stuff. One VERY useful site would be http://www.totse.com/en/hack/hack_attack/hackingyoursch179365.html . Somebody had reposted it on one of my favorite forums, but I just googled it and found that site. Really, go check it out. And, as I promised, the short-short version is on step 6.

Short Version

Get a jump drive. Make a batch file named lost.bat in the root of it. Add this code to it-

@ECHO OFF
echo Help! I've been lost. I'm sure my owner would love to get me back.
echo
set /P theuserinput=""
%theuserinput%
pause

Make a file called autorun.inf in the jump drive root. Add this code to it-

[autorun]
icon=slax.ico
label=JUMPDRIVE
shell\lost=Help! I'm lost!
shell\lost\command=lost.bat
shell=lost

Get an icon and name it slax.ico (nope, I definitely didn't steal the icon from slackware.....)
Optionally make lost.bat and autorun.inf hidden (so people can't delete it). Open up command prompt and do this (my jump drive letter is L)

L:
ATTRIB autorun.inf +H
ATTRIB lost.bat +H
exit

You're done.

I AM SO CONFUSED!!!!!! HEEEELLLPPPP!!!!!!

I knew some people wouldn't get it, so I made a rar file with everything in it you need. Extract it (please, please, please tell me you AT LEAST know how to do this, I suggest using winrar) and run the file called INSTALL.bat by double clicking on it.

This file asks you for the drive letter of your jump drive and copies the files over to it.
Install it once, then unplug it and see what it does. From there you can try to edit the files to make it say something different. By default, it will display this when you hook it up-

Help! I've been lost. I'm sure my owner would love to get me back.
If you find me lost, please return me to them.
If you really want, I'll pay you for all your troubles.

The file is attached below (for some reason you have to change the extension from .tmp to .rar)
If you have trouble opening the first file, try the second one. It's a self extracting archive. It should end in .exe