Launch WinBatch from Internet Explorer Context Menu
Keywords: Internet Explorer IE Context Right Click Menu Selected Text WinBatch Script IE 7 8 9 10 Windows 7 Win7
Question:
I would like to launch a WinBatch script from IE right click context menu. Specifically I would like to send the selected text in IE to my Winbatch script. Can this be done?
Answer:
Yes. However it does require you to modify IE default security settings, which can potentially make your system vulnerable. So use at your own risk.
Its going to require the following steps
- Create HTML file that contains javascript that launches WinBatch.
- Create WBT file that accepts command line parameters from the javascript.
- Modify the registry.
- Modify IE security.
Create HTML
Create HTML file that contains javascript that launches WinBatch. Create an html file called C:\Program Files (x86)\WinBatch\Addons\ExtendIE\\WB_GetSelection.html
<SCRIPT LANGUAGE="JavaScript">
var parentwin = external.menuArguments; var doc = parentwin.document;
var sel = doc.selection; var rng = sel.createRange(); var str = new String(rng.text);
var oShell = new ActiveXObject("Shell.Application");
// Replace with your executable name
oShell.ShellExecute('c:\\Program Files\\WinBatch\\System\\WinBatch.exe', '"C:\\Program Files (x86)\\WinBatch\\Addons\\ExtendIE\\WB_GetSelection.wbt" "' + str + '"');
oShell = null;
</SCRIPT>
Create WBT
Create WBT file that accepts command line parameters from the javascript. Create a WBT file called C:\Program Files (x86)\WinBatch\Addons\ExtendIE\\WB_GetSelection.wbt
Pause('Highlighted Webpage Text',Param1)
Modify the registry.
- Launch regedit.
- Create a registry key: HKCU\Software\Microsoft\Internet Explorer\MenuExt\WB_GetSelection
- For the Default value specify: C:\Program Files (x86)\WinBatch\Addons\ExtendIE\WB_GetSelection.htm
- Create a new DWORD value named "Contexts" and give it the value of 1.
Modify IE security
- Now Launch the Internet Explorer web browser.
- Click the "Tools" menu and then click "Internet Options."
- Click the "Security" tab.
- Click to select "Local Intranet" from the listed zones and then click the "Custom Level" button.
- Scroll down to the "Scripting" options.
- Click to select "Enable" next to the "Active Scripting" option.
- Click the "OK" button and then click "Yes" to approve the new scripting setting.
- Click "Apply" and "OK." Restart the Internet Explorer.
Reference: http://stackoverflow.com/questions/8834010/how-can-i-create-an-internet-explorer-addon
Article ID: W17939
Filename: Launch WinBatch from Internet Explorer Context Menu .txt
File Created: 2013:10:01:08:11:36
Last Updated: 2013:10:01:08:11:36