Running Scripts Directly From the Context Menu in Windows XP

by SirSmiley in Circuits > Microsoft

6366 Views, 7 Favorites, 0 Comments

Running Scripts Directly From the Context Menu in Windows XP

1_12.jpg
This originally developed out of a thread over at Aqua-soft.org about
Creating an "Empty-able" Folder. Making an "Empty-able" Folder

Someone wanted to be able to empty the contents of a their download folder without
deleting the folder. Before jumping to the obvious delete & create a new folder
suggestion there are a number of reasons someone would want this done this way.

The main reason is if you have scripts or multiple apps that reference that particular folder than
you would need to make sure everything was closed before using the standard
window features depending on each programs needs.

So, I hacked together a number of scripts to be used from the Sendto menu but, was
looking into a more direct option. Enter Fast Explorer, which had been sitting around
on my drive waiting for a try.

What you'll need.

Fast Explorer 2007 (Freeware)
http://thesoftpro.tripod.com/downloads/fe/index.htm

Microsoft Script Host
http://www.microsoft.com/downloads/results.aspx?pocId=&freetext=Windows%20Script%20Host&DisplayLang=en

Administrative Level Access to your computer
(this is an assumption as I haven't tried it under a limited account)

The two scripts attached at the end of this instructable:
Empty_Folder.vbs
Delete_to_Recycle_Bin.vbs*

*Note: This script doesn't work on Vista

Add Item to the Folder Context Menu

1_01.jpg
1_02.jpg
1_03.jpg
1_04.jpg
1_05.jpg
1_06.jpg
1_07.jpg
1_08.jpg
1_09.jpg
1_10.jpg
1_11.jpg
1_12.jpg
These are the steps to follow in order to run a script from any folder context menu.

1. Start Fast Explorer
2. Select the Static Items Tab
3. Under Menu Items Choose Add
4. Under Item Details section select the browse button beside the Application box
5. Browse to your Windows\System32 folder and select wscript.exe (this is the script host)
6. Next Select the Parameters text box and type in the path to the script file as follows:
"C:\MyFolder\Empty_Folder.vbs" "%1"
(*Note if the above parameter doesn't work then try a dos path to the file or "%I")
7. In Item Details section, next Select the drop down box beside File Type and select Folder.
8. Now go back to the Menu Items Section and right click on the Item
9. Choose Rename and enter the name you want.
10. Select apply. (Bottom right corner)

*Don't choose okay since we will be using Fast Explorer again.

Open explorer and right click on a folder and your new item should be visible in the
context menu.

Create a Submenu and Add an Item

2_01.jpg
2_02.jpg
2_03.jpg
2_04.jpg
2_05.jpg
2_06.jpg
2_07.jpg
2_08.jpg
2_09.jpg
2_10.jpg
2_11.jpg
2_12.jpg
2_13.jpg
This will demonstrate how to create a folder context menu submenu and add an item to it.

Continuing on from before or open Fast Explorer if you happened to close it.
1. Select the Submenu Items Tab
2. Under Menu Items Section Select Item Button
3. Choose Add Submenu from the drop down menu
4. Right click on the new menu and choose rename Your Menu
5. Under Item Details Section choose the Folder from the File Type drop down box
(this will make sure the item shows on folder right click menu only)
6. Under Menu Items Section Select Item Button
7. Choose Add Add Item from the drop down menu
8. Under Item Details Section choose the browse button beside Application and Browse to Wscript.exe
9. Type Parameters:
"C:\Mgmt\scripts\Context\DELETE~1.VBS" %1
10. Choose File Type: Folder (If not already chosen)
11. Under Menu Items Section Right click the item or hit F2 then rename Item
12. Choose Apply (Bottom Right Corner)

Browse to a folder in explorer and right click
There should be a new item Called My Folder Tools
Click on this should display your submenu.

Files & Assorted Notes

Warning: The first script permanently deletes files and both scripts delete the entire contents of the chosen folder

This has been tested on Windows XP but, may Fast Explorer is suppose to be Vista Compatible.

Empty_Folder.vbs
- This script uses the FileSystemObject and bypasses the recycle bin.
- The fastest script

Delete_to_Recycle_Bin.vbs
- This script uses the Invoke Verb method to move items
- It calls the Shell.Application which I believe is part of the reason it won't run on vista
- noticeably slower