Web lists-archives.com

Re: open IE from command line




On 21 December 2016 at 18:04, Doug Henderson  wrote:
> On 21 December 2016 at 10:01, Nellis, Kenneth wrote:

> Attached is a bash script, renamed as openurl.sh.txt, which will open
> a url with either the default browser or Internet Explorer. It takes

Last minute fix: before using the script, edit it to repair a copy/paste error.

26,26s/CMD/COMSPEC/

i.e. in line 26, both variable references should be to COMSPEC.


Attached is repaired copy

-- 
Doug Henderson, Calgary, Alberta, Canada - from gmail.com
#!/bin/bash
# Copyright (c) 2016 Doug Henderson
# Licence: GPL3
# Version: 1.0
#
# openurl[.sh] [IE] URL
#
# Open a URL in the default browser or in Internet Explorer.
# This will work properly when using CYGWIN_NOWINPATH=1
# Tested on Windows 7 Home Premium, Service Pack 1, fully patched
# and CYGWIN_NT-6.1 xxx 2.6.1(0.305/5/3) 2016-12-16 11:55 x86_64 Cygwin
#
# You may rename this file to meet your requirements.
#
# Quote the URL when it contains spaces or shell special characters.
#
# Usage:
#   openurl.sh [IE] URL
#
#   openurl.sh https://www.google.ca
#       open Google search with default browswer
#
#   openurl.sh IE https://www.google.ca
#       open Google search with Internet Explorer
#
if [ -n "${COMSPEC}" -a -x "$( cygpath -Ua "${COMSPEC}" )" ] ; then
    # COMSPEC should contain the absolute windows path
    # to the CMD.EXE executable.
    CMD="${COMSPEC}"
else
    # Hard code path to windows CMD.EXE
    # You may need to change this depending on windows version
    # and install options.
    # Copy/paste from CompSpec variable on Command Prompt window.
    # Double all backslashes.
    CMD="C:\\Windows\\System32\\cmd.exe"
    # echo WARNING: using hardcoded path: ${CMD}
fi

# Make sure we know location of Command program.
if [ ! -x "$( cygpath -Ua "${CMD}" )" ] ; then
    echo ERROR: Please provide path to CMD.EXE
    exit 1
fi

IE="C:\\Program Files\\Internet Explorer\\iexplore.exe"
# echo WARNING: using hardcoded path: ${IE}
# Hardcode the location of the Internet Explorer EXE file.
# Copy/paste from Blue-E shortcut icon properties Target field.
# Double all backslashes.

if [ "$1" = "IE" ] ; then
    # Make sure we know location of Internet Explorer.
    if [ ! -x "$( cygpath -Ua "${IE}" )" ] ; then
        echo ERROR: Please provide path to IEXPLORE.EXE
        exit 1
    fi
    shift
    "$( cygpath -Ua "${CMD}" )" /D /S /C "START /I "${IE}" "$*""
else
    "$( cygpath -Ua "${CMD}" )" /D /S /C "START /I "$*""
fi
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple