DrewNaylor / UXL-Launcher

An app launcher meant to launch Microsoft Office 2010, 2013, 2016, 2019 desktop software/apps, including ones from Office 365. Not associated with Microsoft.
Apache License 2.0
7 stars 1 forks source link

Allow the user to choose if they want to simply have UXL Launcher to use "Process.Start(exeName)" for certain applications instead of the entire path. #109

Closed DrewNaylor closed 4 years ago

DrewNaylor commented 6 years ago

Examples of applications that this works with in Office 2010 are as follows:

This can be in the form of a checkbox in the Options window General tab. The text could be as follows: Bypass drive location, Office version, installation method, and Windows edition preferences for supported apps

The tooltip could be as follows: Supported apps include Word, Excel, PowerPoint, Outlook, OneNote, Access, and Publisher for most versions of Office. Instead of using your choices on this page to figure out which directory to launch apps from, we'll just run the EXE file of the app you choose, just like if they were typed into the Run dialog. The "Test settings" button won't use this bypass.

DrewNaylor commented 6 years ago

If this option is enabled and the application the user launches supports being started like this, then don't use the full path. However, if it's not enabled, just launch the app the regular way. This could be done with a combination of LaunchApp.vb and isolated_error_handler.vb modifications, maybe like so:

LaunchApp.vb changes for a supported app:

Before:


#Region "Microsoft Access Launcher Code."
    Public Shared Sub LaunchAccess()
        ' Launch Microsoft Access. Try...Catch code source here: <http://www.homeandlearn.co.uk/NET/nets5p4.html>
        isolated_error_handler.launcherErrorHandler("MSACCESS.EXE", "Microsoft Access")
    End Sub
#End Region

After:


#Region "Microsoft Access Launcher Code."
    Public Shared Sub LaunchAccess()
        ' Launch Microsoft Access. Try...Catch code source here: <http://www.homeandlearn.co.uk/NET/nets5p4.html>
        If My.Settings.bypassFolderPrefs = True Then
        ' If the folder location bypass is enabled, just run "MSACCESS.EXE".
            isolated_error_handler.launcherErrorHandler("MSACCESS.EXE", "Microsoft Access", True)
        Else
        ' Otherwise, use the folder location.
            isolated_error_handler.launcherErrorHandler("MSACCESS.EXE", "Microsoft Access")
    End Sub
#End Region

isolated_error_handler.vb changes:

Before:


Public Class isolated_error_handler
    Public Shared Sub launcherErrorHandler(Optional launcherErrorHandler_ExeName As String = "ExeToLaunch.exe", Optional launcherErrorHandler_ExeFriendlyName As String = "Application Name Here")
        Try
            Process.Start(OfficeLocater.fullLauncherCodeString & launcherErrorHandler_ExeName)
        Catch ex As System.ComponentModel.Win32Exception
            ' If Microsoft Access isn't found in the folder the user chose in the Options window, ask them if they want to
            ' go to the Options window to change it.
            Dim msgResult As Integer = MessageBox.Show("We couldn't find " & launcherErrorHandler_ExeFriendlyName & " in the location specified in the Options window." &
            " Would you like to open the Options window to change your settings?" & vbCrLf &
                "" & vbCrLf &
                "Full error message: " & ex.Message, "Couldn't find file",
            MessageBoxButtons.YesNo, MessageBoxIcon.Error)

            ' If the user chooses to open the Options window, open the Options window to the General tab.
            If msgResult = DialogResult.Yes Then
                Dim forceOptionsWindowTab As New aaformOptionsWindow
                forceOptionsWindowTab.tabcontrolOptionsWindow.SelectTab(0)
                forceOptionsWindowTab.ShowDialog(aaformMainWindow)
            End If
        Catch ex As Exception
            ' If another error shows up, then we can't handle it yet and ask the user if they want to file a
            ' bug report.
            Dim msgResult As Integer = MessageBox.Show("An error occurred that we can't handle yet. Would you like to file a bug report online?" & vbCrLf & "Before clicking ""Yes,"" please write down what you were doing" & vbCrLf & "when the error occurred along with the text below" &
                " and use that to fill out the bug report." & vbCrLf &
                "" & vbCrLf &
                "Error message: " & vbCrLf & ex.Message & vbCrLf & "Error type:" & vbCrLf & ex.GetType.ToString, "I just don't know what went wrong!",
            MessageBoxButtons.YesNo, MessageBoxIcon.Error)
            ' If the user chooses to file a bug report online, go to the GitHub Issues "New Issue."
            If msgResult = DialogResult.Yes Then
                Process.Start("https://github.com/DrewNaylor/UXL-Launcher/issues/new")
            End If
        End Try
    End Sub
End Class

After:


Public Class isolated_error_handler
    Public Shared Sub launcherErrorHandler(Optional launcherErrorHandler_ExeName As String = "ExeToLaunch.exe", Optional launcherErrorHandler_ExeFriendlyName As String = "Application Name Here", Optional launcherErrorHandler_bypassFolderPrefs As Boolean = False)
        Try
            If launcherErrorHandler_bypassFolderPrefs = True Then
                ' Just run the EXE file as if the user is launching it from the Run dialog if the user wants to bypass the folder preferences and the app supports it.
                Process.Start(launcherErrorHandler_ExeName)
            Else
                ' If the app doesn't support it, or the user doesn't want to bypass the folder preferences, use the folder location.
            Process.Start(OfficeLocater.fullLauncherCodeString & launcherErrorHandler_ExeName)
        Catch ex As System.ComponentModel.Win32Exception
            ' If Microsoft Access isn't found in the folder the user chose in the Options window, ask them if they want to
            ' go to the Options window to change it.
            Dim msgResult As Integer = MessageBox.Show("We couldn't find " & launcherErrorHandler_ExeFriendlyName & " in the location specified in the Options window." &
            " Would you like to open the Options window to change your settings?" & vbCrLf &
                "" & vbCrLf &
                "Full error message: " & ex.Message, "Couldn't find file",
            MessageBoxButtons.YesNo, MessageBoxIcon.Error)

            ' If the user chooses to open the Options window, open the Options window to the General tab.
            If msgResult = DialogResult.Yes Then
                Dim forceOptionsWindowTab As New aaformOptionsWindow
                forceOptionsWindowTab.tabcontrolOptionsWindow.SelectTab(0)
                forceOptionsWindowTab.ShowDialog(aaformMainWindow)
            End If
        Catch ex As Exception
            ' If another error shows up, then we can't handle it yet and ask the user if they want to file a
            ' bug report.
            Dim msgResult As Integer = MessageBox.Show("An error occurred that we can't handle yet. Would you like to file a bug report online?" & vbCrLf & "Before clicking ""Yes,"" please write down what you were doing" & vbCrLf & "when the error occurred along with the text below" &
                " and use that to fill out the bug report." & vbCrLf &
                "" & vbCrLf &
                "Error message: " & vbCrLf & ex.Message & vbCrLf & "Error type:" & vbCrLf & ex.GetType.ToString, "I just don't know what went wrong!",
            MessageBoxButtons.YesNo, MessageBoxIcon.Error)
            ' If the user chooses to file a bug report online, go to the GitHub Issues "New Issue."
            If msgResult = DialogResult.Yes Then
                Process.Start("https://github.com/DrewNaylor/UXL-Launcher/issues/new")
            End If
        End Try
    End Sub
End Class
DrewNaylor commented 6 years ago

This checkbox could work well on the Options window Advanced tab, below the groupbox for Windows edition.

DrewNaylor commented 6 years ago

This would be a nice addition below the checkbox described in #35. When that checkbox is unchecked, this one will be disabled. A good name for this checkbox would be, "Do this for all supported apps"

DrewNaylor commented 4 years ago

This is now possible for all apps that support being launched from the Run dialog, but the checkbox in the Options window isn't added yet.