Wednesday, January 19, 2011

Detecting the Insertion of USB Flash in Batch Files

How to detect that user inserts USB Flash drive and make computer shut down after this? Here you can see step-by-step explanation.
1. Download and install Dr.Batcher, the program designed to create and edit batch files.
2. Start Dr.Batcher and create new empty batch script (File->New->Empty Batch Script).
3. Add command named "Display a message" (Command->Add), click OK in the "Add Command" dialog.
4. Choose "off" as the first parameter and click "OK".
5. Add command named "Set Label".
6. Set loop as a label name, click "OK".
7. Add command named "If (Condition)". Choose "Edit the condition" in the appeared dialog.
8. Choose "File Exists (Condition Only)". 9. Set the letter of the flash drive as the parameter in the following dialog. Note: "\." after the drive letter should not be removed.
9. Add command named "Go to a Label".
10. Set loop as the label name. Click "OK".
11. Following the instructions in paragraphs 5 and 6, add a label with name end.
12. Add command named "Shut Down or Restart Computer".
13. Set the first parameter of this command equal to -r to restart or -s to shut down
14. To make this file start automatically when you log on, place it inside the "Startup" folder in Start menu.
15. Enjoy!

No comments:

Post a Comment

Translate