Skip to content

Commit

Permalink
Merge pull request #80 from felixrieseberg/do-not-delete-uninstall-re…
Browse files Browse the repository at this point in the history
…g-key-when-removing-autoupdater

fix: do not delete uninstall reg when removing auto-updater
  • Loading branch information
bitdisaster committed May 19, 2020
2 parents 0007b54 + 84d8561 commit bdee6cb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export class MSICreator {
});
const childFiles = tree.__ELECTRON_WIX_MSI_FILES__
.map((file) => {
const component = this.getComponent(file, indent + 2);
const component = this.getFileComponent(file, indent + 2);
this.components.push(component);
return component.xml;
});
Expand Down Expand Up @@ -523,9 +523,9 @@ export class MSICreator {
* Creates Wix <Components> for all files.
*
* @param {File}
* @returns {FileComponent}
* @returns {RegistryComponent}
*/
private getComponent(file: File, indent: number): FileComponent {
private getFileComponent(file: File, indent: number): FileComponent {
const guid = uuid();
const componentId = this.getComponentId(file.path);
const xml = replaceInString(this.fileComponentTemplate, {
Expand All @@ -544,7 +544,7 @@ export class MSICreator {
* Creates Wix <Components> for all registry values.
*
* @param {File}
* @returns {FileComponent}
* @returns {RegistryComponent}
*/
private getRegistryComponent(registry: Registry, indent: number): Component {
const guid = uuid();
Expand All @@ -561,6 +561,8 @@ export class MSICreator {
'{{Key}}': registry.key,
'{{Type}}': registry.type,
'{{Value}}': registry.value,
'{{ForceCreateOnInstall}}': registry.forceCreateOnInstall || 'no',
'{{ForceDeleteOnUninstall}}': registry.forceDeleteOnUninstall || 'no',
'<!-- {{Permission}} -->': permissionXml
});
return { guid, componentId: registry.id, xml, featureAffinity: registry.featureAffinity || 'main' };
Expand Down Expand Up @@ -632,6 +634,7 @@ export class MSICreator {
key: uninstallKey,
type: 'string',
value: '[APPLICATIONROOTDIRECTORY]',
forceDeleteOnUninstall: 'yes'
});

// The following keys are for our uninstall entry because we hiding the original one.
Expand All @@ -643,6 +646,7 @@ export class MSICreator {
key: uninstallKey,
type: 'string',
value: '[VisibleProductName]',
forceDeleteOnUninstall: 'yes'
});

registry.push({
Expand All @@ -652,6 +656,7 @@ export class MSICreator {
key: uninstallKey,
type: 'string',
value: '{{Manufacturer}}',
forceDeleteOnUninstall: 'yes'
});

registry.push({
Expand All @@ -661,6 +666,7 @@ export class MSICreator {
key: uninstallKey,
type: 'string',
value: '{{SemanticVersion}}',
forceDeleteOnUninstall: 'yes'
});

registry.push({
Expand All @@ -670,6 +676,7 @@ export class MSICreator {
key: uninstallKey,
type: 'expandable',
value: 'MsiExec.exe /I {{{ProductCode}}}',
forceDeleteOnUninstall: 'yes'
});

registry.push({
Expand All @@ -679,6 +686,7 @@ export class MSICreator {
key: uninstallKey,
type: 'expandable',
value: 'MsiExec.exe /X {{{ProductCode}}}',
forceDeleteOnUninstall: 'yes'
});

registry.push({
Expand All @@ -688,6 +696,7 @@ export class MSICreator {
key: uninstallKey,
type: 'expandable',
value: this.arch === 'x86' ? '[SystemFolder]msiexec.exe' : '[System64Folder]msiexec.exe',
forceDeleteOnUninstall: 'yes'
});

if (this.autoUpdate) {
Expand All @@ -704,7 +713,8 @@ export class MSICreator {
permission: {
user: '[UPDATERUSERGROUP]',
genericAll: 'yes'
}
},
forceCreateOnInstall: 'yes',
});

registry.push({
Expand All @@ -715,6 +725,7 @@ export class MSICreator {
type: 'integer',
value: '1',
featureAffinity: 'autoUpdate',
forceDeleteOnUninstall: 'yes'
});
}

Expand All @@ -726,7 +737,8 @@ export class MSICreator {
key: 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run',
type: 'string',
value: '[APPLICATIONROOTDIRECTORY]{{ApplicationBinary}}.exe',
featureAffinity: 'autoLaunch'
featureAffinity: 'autoLaunch',
forceDeleteOnUninstall: 'yes'
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface Registry extends AppElement {
name: string;
value: string;
type: 'string' | 'integer' | 'binary' | 'expandable' | 'multiString';
forceCreateOnInstall?: 'yes' | 'no';
forceDeleteOnUninstall?: 'yes' | 'no';
permission?: {
user: string;
genericAll: 'yes' | 'no';
Expand Down
2 changes: 1 addition & 1 deletion static/registry-component.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- {{I}} --><Component Id="{{ComponentId}}" Guid="{{Guid}}" Win64="{{Win64YesNo}}">
<!-- {{I}} --> <RegistryKey Root="{{Root}}" Key="{{Key}}" ForceDeleteOnUninstall="yes">
<!-- {{I}} --> <RegistryKey Root="{{Root}}" Key="{{Key}}" ForceCreateOnInstall="{{ForceCreateOnInstall}}" ForceDeleteOnUninstall="{{ForceDeleteOnUninstall}}">
<!-- {{I}} --> <!-- {{Permission}} -->
<!-- {{I}} --> <RegistryValue Name="{{Name}}" Type="{{Type}}" Value="{{Value}}" KeyPath="yes"/>
<!-- {{I}} --> </RegistryKey>
Expand Down

0 comments on commit bdee6cb

Please sign in to comment.