Forráskód Böngészése

Closes #2130

Prevent Windows installation if app is running
Armin Schrenk 3 éve
szülő
commit
1a0624cc81
2 módosított fájl, 45 hozzáadás és 3 törlés
  1. 25 2
      dist/win/resources/customWizard.wxi
  2. 20 1
      dist/win/resources/main.wxs

+ 25 - 2
dist/win/resources/customWizard.wxi

@@ -13,7 +13,6 @@
 			<DialogRef Id="BrowseDlg" />
 			<DialogRef Id="DiskCostDlg" />
 			<DialogRef Id="ErrorDlg" />
-			<DialogRef Id="FatalError" />
 			<DialogRef Id="FilesInUse" />
 			<DialogRef Id="MsiRMFilesInUse" />
 			<DialogRef Id="PrepareDlg" />
@@ -24,8 +23,9 @@
 			<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
 			<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
 
-			<!-- custom end dialog -->
+			<!-- custom end dialogs -->
 			<Publish Dialog="MyExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
+			<Publish Dialog="MyFatalErrorDlg" Control="Finish" Event="EndDialog" Value="Return" Order="998">1</Publish>
 
 			<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="LicenseAgreementDlg">NOT Installed</Publish>
 			<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
@@ -75,11 +75,34 @@
 				</Control>
 			</Dialog>
 
+			<!-- copy pasta from https://github.com/wixtoolset/wix3/blob/develop/src/ext/UIExtension/wixlib/FatalError.wxs with adjustments-->
+			<Dialog Id="MyFatalErrorDlg" Width="370" Height="270" Title="!(loc.FatalError_Title)">
+                <Control Id="Finish" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUIFinish)">
+                    <Publish Event="EndDialog" Value="Exit">1</Publish>
+                </Control>
+                <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Disabled="yes" Text="!(loc.WixUICancel)" />
+                <Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.FatalErrorBitmap)" />
+                <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Disabled="yes" Text="!(loc.WixUIBack)" />
+                <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
+                <Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.FatalErrorTitle)" />
+                <Control Id="Description" Type="Text" X="135" Y="70" Width="220" Height="80" Transparent="yes" NoPrefix="yes" Text="!(loc.FatalErrorDescription1) !(loc.FatalErrorDescription2)" />
+                <Control Id="DescriptionReason1" Type="Text" X="135" Y="160" Width="220" Height="20" Transparent="yes" NoPrefix="yes" Hidden="yes" >
+					<Text>Reason:</Text>
+                    <Condition Action="show">FOUNDRUNNINGAPP</Condition>
+                </Control>
+                <Control Id="DescriptionReason2" Type="Text" X="135" Y="170" Width="220" Height="40" Transparent="yes" NoPrefix="yes" Hidden="yes" >
+					<Text>Cryptomator was still running during installation.</Text>
+                    <Condition Action="show">FOUNDRUNNINGAPP</Condition>
+                </Control>
+            </Dialog>
+
 			<InstallUISequence>
 				<Show Dialog="MyExitDialog" Overridable="yes" OnExit="success"/>
+				<Show Dialog="MyFatalErrorDlg" Overridable="yes" OnExit="error"/>
 			</InstallUISequence>
 			<AdminUISequence>
 				<Show Dialog="MyExitDialog" Overridable="yes" OnExit="success"/>
+				<Show Dialog="MyFatalErrorDlg" Overridable="yes" OnExit="error"/>
 			</AdminUISequence>
 
 		</UI>

+ 20 - 1
dist/win/resources/main.wxs

@@ -127,6 +127,20 @@
     <!-- WebDAV patches -->
     <CustomAction Id="PatchWebDAV" Impersonate="no" ExeCommand="[INSTALLDIR]patchWebDAV.bat" Directory="INSTALLDIR" Execute="deferred" Return="asyncWait" />
 
+    <!-- Running App detection and exit -->
+    <Property Id="FOUNDRUNNINGAPP" Admin="yes"/>
+    <util:CloseApplication
+      Id="CloseCryptomator"
+      Target="cryptomator.exe"
+      CloseMessage="no"
+      RebootPrompt="no"
+      PromptToContinue="yes"
+      Description="A running instance of Cryptomator is found. Please close it to continue."
+      Property="FOUNDRUNNINGAPP"
+      >
+    </util:CloseApplication>
+    <CustomAction Id="FailOnRunningApp" Impersonate="no" ExeCommand="[SystemFolder]\cmd.exe /c &quot;exit 1&quot;" Directory="INSTALLDIR" Execute="immediate" Return="check" />
+
     <?ifdef JpIcon ?>
     <Property Id="ARPPRODUCTICON" Value="JpARPPRODUCTICON"/>
     <Icon Id="JpARPPRODUCTICON" SourceFile="$(var.JpIcon)"/>
@@ -155,7 +169,12 @@
       <?ifndef JpAllowDowngrades ?>
       <Custom Action="JpDisallowDowngrade" After="FindRelatedProducts">JP_DOWNGRADABLE_FOUND</Custom>
       <?endif?>
-      <RemoveExistingProducts Before="CostInitialize"/>
+
+      <!-- Check and fail if Cryptomator is running -->
+      <Custom Action="WixCloseApplications" Before="InstallValidate"></Custom>
+      <Custom Action="FailOnRunningApp" After="WixCloseApplications" >FOUNDRUNNINGAPP</Custom>
+
+      <RemoveExistingProducts After="InstallValidate"/>
 
       <Custom Action="PatchWebDAV" After="InstallFiles">NOT Installed OR REINSTALL</Custom>
     </InstallExecuteSequence>