MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: BASIC (URL Shortcut)[Next]: SourceFile
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Source Code->Commands->ShortcutUrl->IE (URL Shortcut)

IE (URL Shortcut)

This section describes the "IE" mode of the "ShortcutUrl" command.

IE automation is used to invoke the URL. You can set the titlebar title and bring existing windows into focus etc. You can control window sizes and menus but of course this is an Internet Explorer only solution which will not work if IE is unavailable.

This mode of the "ShortcutUrl" command takes these parameters:

CONFIGURATION - OPTIONS

The following are the generic options available:

#define? DEFAULT_SHORTCUTURL_HOW                  BASIC   ;;Default mechanism used to create URL Shortcuts
#define? DEFAULT_ADD_GENERATED_RESOURCES_TO_DOCO  N

The following are the options available for the "IE mode":

#define? DEFAULT_SHORTCUTURL_IE_INSTALLDIR                             ;;BLANK=parameter required, else default DIR KEY
#define? SHORTCUTURL_IE_VBSCRIPT_INITIALIZATION_CODE                   ;;Hook for defining variables etc...
#define? SHORTCUTURL_IE_VBSCRIPT_SUPPORTING_FUNCTIONS_AND_SUBROUTINES  ;;Hook for adding your own functions (which your inserted code will use)
#define? SHORTCUTURL_IE_REUSE_EXISTING_WINDOW_IF_POSSIBLE  Y           ;;Look for and use any already open URL?
#define? SHORTCUTURL_IE_RESIZING_CRITICAL                  N           ;;Should we abort if we can't correctly size the window (IE7 security etc)?
#define? DEFAULT_SHORTCUTURL_IE_FEATURE                    .           ;;Blank means non-advertised shortcut or feature name or "." or "\"
#define? SHORTCUTURL_IE_KEYPATH_TYPE_FOR_COMPONENTS  CU=Y              ;;Current User Keypath by default (for non advertised IE shortcuts)
#(  '<?NewLine>'
    #define? SHORTCUTURL_LOGLINE_INITIALIZATION

    '--- First time in? -------------------------------------------------
    if  ScLogFile <> "" then
        '--- We have already initialized everything :-) ---------------------
        How = LogAppend
    else
        '--- Need to initialize things :-) ------------------------------
        How = LogCreate

        '--- Determine the filename (use "CreateDirectoryTree()" to create directories) ---
        LogsDir   = GetEnvDieOpt("TEMP", false)
        ScLogFile = LogsDir & "\ShortcutUrl_4_" & WantedTitle &  ".log.txt"
    end if
#)
#(  '<?NewLine>'
    #define? SHORTCUTURL_IE_VBSCRIPT_DIE_DISPLAY_MESSAGE

    ;--- Some available Variables -------------------------------------------
    ; Text   - The message passed to Die()

    Text = "Sorry but we couldn't launch the browser." & vbCRLF & vbCRLF & Text
    LogLine "MSGBOX - SHORTCUTURL_IE_VBSCRIPT_DIE_DISPLAY_MESSAGE"
    LogLine "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    LogLine Text
    MsgBox Text, vbCritical+vbSystemModal, "<$ProdInfo.ProductName> ERROR"
#)
#(  '<?NewLine>'
    #define? SHORTCUTURL_IE_HOOK_OBJECT_UPDATE                         ;;Code to do any unsupported object manipulations

    ;--- Some available Variables -------------------------------------------
    ; oIE    - IE automation object
    ; Die()  - Subroutine to display error message (only parameter) and abort
#)
#(  '<?NewLine>'
    #define? SHORTCUTURL_IE_HOOK_UPDATE_URL_JUST_BEFORE_LAUNCH_NEW_IE_SESSION  ;;Intended to allow you to add parameters to the URL etc.

    ;--- Some available Variables -------------------------------------------
    ; URL    - Contains the URL we are about to launch (you can add parameters etc)
    ; Die()  - Subroutine to display error message (only parameter) and abort
#)
#(  '<?NewLine>'
    #define? SHORTCUTURL_IE_UPDATE_TITLE_VB_STATEMENTS                 ;;How should the Window Title be set (if at all)

    ;--- Some available Variables -------------------------------------------
    ; oWindow - Window Object of the IE session containing the launched window
    ; Die()   - Subroutine to display error message (only parameter) and abort
    <?NewLine>

    '--- The old DEFAULT was very simple, just set it (from "IeTitleBar" parameter) -----
    'oWindow.document.title = WantedTitle
    <?NewLine>

    ;--- Some pages will try to change the title back.... -------------------
    LogLine ""
    LogLine ""
    LogLine "ImproveIeTitleBarTitle(""" & WantedTitle & """)"
    LogInc()
        if  WantedTitle = "" then
            ;--- Dont Want the title changed --------------------------------
            LogLine "We have not been asked to change the title after all..."
        else
            '--- Default very simple, just set it (from "IeTitleBar" parameter) ---
            dim NagCnt
            for NagCnt = 1 to 20
                ;--- Sleep for 500ms --------------------------------------------
                wscript.Sleep 500
                dim CurrentTitle : CurrentTitle = "?unknown?" : CurrentTitle = oWindow.document.title
                err.clear()
                LogLine "#" & NagCnt & ", CURRENT TITLE: " & CurrentTitle

                ;--- Is the title already correct? --------------------------
                if  CurrentTitle <> WantedTitle then
                    ;--- Current title is not what we want ------------------
                    LogInc()
                        ;--- Try to change the title -------------------------
                        err.clear()
                        oWindow.document.title = WantedTitle
                        if  err.number = 0 then
                            LogLine "Successfully changed the title..."
                        else
                            ;--- Failed to set the title, show reason -------
                            dim ErrNumber : ErrNumber = err.number
                            LogLine "Failed setting the new title! Reason: 0x" & hex(ErrNumber) & " - " & err.description

                            ;--- Did the above fail due to the issue we have a workaround for? ---
                            FixMicrosoftsIeIntegrityIssueIfRequired ErrNumber, oWindow
                        end if
                    LogDec()
                end if
            next
        end if
        LogLine "ImproveIeTitleBarTitle() - FINISHED"
    LogDec()
#)
#(  '<?NewLine>'
    ;--- Actual code included into the function -----------------------------
    #define? DEFAULT_SHORTCUTURL_IECOMPARE

    ;--- Some available Variables -------------------------------------------
    ; oWindow        - Window Object of an IE session we are looking at
    ; AlreadyStarted - Return code - You must set to true or false
    ; LaunchUrl      - Copy of the URL being launched (you can modify if you wish - won't change whats launched)
    ; Die()          - Subroutine to display error message (only parameter) and abort

    ;--- By default window matches if window URL begins with wanted URL (less any page info) ----
    <$SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL_LOCATION>
#)


;----------------------------------------------------------------------------
;--- Two different "sample" types of IE Window comparison mechanisms --------
;----------------------------------------------------------------------------
#(  '<?NewLine>'
    ;--- Simple compare, the windows URL begins with the launch URL (minus any page info) ---------
    #define? SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL_LOCATION

    ;--- Log What we are doing ----------------------------------------------
    LogLine "SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL_LOCATION, Window's URL is: " & oWindow.LocationURL
    LogInc()
        ;--- If a page attached to URL then remove it ---------------------------
        if  right(LaunchUrl, 1) <> "/" then
            ;--- The Launch URL contains page information (directories end with "/") ---
            dim Pos : Pos = InStrRev(LaunchUrl, "/")
            if  Pos <> 0 then
                ;--- Make sure we haven't found "protocol://" -------------------
                if  mid(LaunchUrl, Pos-1, 1) <> "/" then
                    ;--- No unexplained error, so shorten URL to bit we care about ---
                    LaunchUrl = left(LaunchUrl, Pos)
                end if
            end if
        end if
        LogLine " Matching against the launch URL: " & LaunchUrl
        dim MatchLength : MatchLength = len(ucase(LaunchUrl))
        AlreadyStarted = ucase(left(oWindow.LocationURL, MatchLength)) = ucase(LaunchUrl)
    LogDec()
#)
#(  '<?NewLine>'
    ;--- Simple compare, the windows URL begins with the launch URL ---------
    #define? SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL

    ;--- Log What we are doing ----------------------------------------------
    LogLine "SHORTCUTURL_IE_WINDOW_COMPARE_VBSCRIPT-WINDOW_URL_STARTS_WITH_WANTED_URL, Window's URL is: " & oWindow.LocationURL

    dim MatchLength : MatchLength = len(ucase(LaunchUrl))
    AlreadyStarted = ucase(left(oWindow.LocationURL, MatchLength)) = ucase(LaunchUrl)
#)

An Easy Way to Determine a HotKey's Value

Windows allows you to set a hotkey for any shortcut by right clicking on one and opening its properties. Now a IE shortcut (URL) is a text file in the form of an INI file which means that this information is stored in a text format which can be viewed with any text editor!

So to work out the hotkey create an IE shortcut, right click and select properties, now enter the shortcut, press "apply". Open a command prompt and either type the shortcut file or load in a text editor (the file will have a ".URL" file extension), the following shows the shortcut, its properties windows as well as the shortcut opened in notepad:

Implementation Details

The following information may help you if you are trying to alter the defaults (as it will help you find object documentation etc):

EXAMPLE

#(
    <$ShortcutUrl
               HOW="IE"
             Title="Google (via IE automation)"
       Description="A tooltip for this shortcut..."
               Url="http://www.google.com/"
          IconFile="Google.ico"
               Dir="DesktopFolder"
        InstallDir="INSTALLDIR"
    >
#)


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: BASIC (URL Shortcut)[Next]: SourceFile


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.