open IE from command line

Doug Henderson djndnbvg@gmail.com
Thu Dec 22 01:04:00 GMT 2016


On 21 December 2016 at 10:01, Nellis, Kenneth wrote:
>
> From: Nellis, Kenneth
> > I suspect the issue is that some required DLLs are not in
> > my PATH. Indeed, my Cygwin PATH is a pruned version of my
> > Windows PATH.
>
> Actually, that's not the case and is irrelevant as Lee demon-
> strates in https://cygwin.com/ml/cygwin/2016-12/msg00220.html.
>
> Comparing the output from
> Windows: C:/>path
> and
> cygwin/bash: $ cmd /c path
> shows only new paths added to support Cygwin.
>
> I'm on Microsoft Windows 7 Enterprise Edition, 64-bit Service Pack 1 (build 7601)
>
> FWIW, output from "cygcheck -svr" attached.
>
> --Ken Nellis


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
care of the case when CYGWIN_NOWINPATH=1, and where COMSPEC does not
exist in the environment or does not point to an executable program or
when /cygdrive/c/ does not point to the C: disk.

Before using, strip CRs (just in case) using d2u (or dos2unix), rename
to openurl or openurl.sh or ..., place in your path, eg. $HOME/bin and
make executable.

HTH,
Doug

-- 
Doug Henderson, Calgary, Alberta, Canada - from gmail.com
-------------- next part --------------
#!/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 "${CMD}" )" ] ; 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
-------------- next part --------------

--
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


More information about the Cygwin mailing list