Link to home
Start Free TrialLog in
Avatar of crepair
crepair

asked on

Create ".BAT" file to "Start & Shut Down" Internet Explorer USING A KEYBOARD Key? WIN XP

I'm new to using BATCH files, therefore my knowledge is extremely limited.

I'm using WIN XP Pro!

My question:

How do I create a ".BAT" file using "notepad" to "Start & Shut Down" Internet Explorer by USING A KEY ON MY KEYBOARD?

A Detailed answer would be greatly appreciated since my knowledge with batch files is very limited.

THANKS A BUNCH!
Avatar of oBdA
oBdA

Save this batch someplace as SwitchIE.cmd (or whatever you want to name it). Create a shortcut to it someplace. Right-click the shortcut, choose "Properties", and enter a key in the "Key combination" field ("I", for example). In addition, set the shortcut to start the command in a minimized window (IE will still appear in a regular window).
The script will (without further warning) close any open instances of IE if it finds some; if it doesn't, it will start IE instead.

====8<----[SwitchIE.cmd]----
@echo off
setlocal
set Process=%ProgramFiles%\Internet Explorer\iexplore.exe

for %%a in ("%Process%") do set ExeFile=%%~nxa

tasklist | find /i "%ExeFile%" >NUL
if errorlevel 1 (
  start "" "%Process%"
) else (
  taskkill %ExeFile% >NUL
)
====8<----[SwitchIE.cmd]----
The script errored when I ran it.

ERROR: Invalid Argument/Option - 'iexplore.exe'.
Type "TASKKILL /?" for usage.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial