Skip to content

Commit

Permalink
Merge pull request gitextensions#7309 from mast-eu/7308-ConstrainedLa…
Browse files Browse the repository at this point in the history
…nguageMode

Fix installer when PS is in ConstrainedLanguage mode
  • Loading branch information
RussKie authored Oct 16, 2019
2 parents a5904a1 + 31d4f41 commit 04f193e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 11 additions & 4 deletions Bin/set-telemetry.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@ Param(

[bool]$telemetryEnabled = -not [string]::IsNullOrEmpty($Enabled);

if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage")
{
exit 0
}

[string]$userAppDataPath = Join-Path -Path $env:APPDATA -ChildPath 'GitExtensions\GitExtensions\GitExtensions.settings'
if (-not (Test-Path -Path $userAppDataPath)) {
'<?xml version="1.0" encoding="utf-8"?><dictionary />' | Out-File $userAppDataPath -Encoding utf8
[string]$userAppDataFolder = Split-Path $userAppDataPath -Parent
if (-not (Test-Path -Path $userAppDataFolder)) {
New-Item -ItemType Directory -Path $userAppDataFolder | Out-Null
}

'<?xml version="1.0" encoding="utf-8"?><dictionary />' | Out-File $userAppDataPath -Encoding utf8
}

[xml]$doc = Get-Content $userAppDataPath
Expand All @@ -32,6 +42,3 @@ $node = $doc.CreateElement('item');
$node.InnerXml = "<key><string>TelemetryEnabled</string></key><value><string>$telemetryEnabled</string></value>";
$_ = $topNode.AppendChild($node);
$doc.Save($userAppDataPath)

# this script now deletes itself
Remove-Item $MyINvocation.InvocationName
3 changes: 1 addition & 2 deletions Setup/UI/TelemetryDlg.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
<![CDATA[Installed OR POWERSHELLEXE]]>
</Condition>

<!-- Windows 7SP1 supports only PowerShell 2.0 -->
<SetProperty Id="ConfigureTelemetry"
Before ="ConfigureTelemetry"
Sequence="execute"
Value="&quot;[POWERSHELLEXE]&quot; -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command &quot;&amp; '[INSTALLDIR]set-telemetry.ps1' [TELEMETRY_ENABLED] ; exit $$($Error.Count)&quot;" />
Value="&quot;[POWERSHELLEXE]&quot; -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command &quot;&amp; '[INSTALLDIR]set-telemetry.ps1' [TELEMETRY_ENABLED]; exit $$($Error.Count)&quot;" />

<CustomAction Id="ConfigureTelemetry" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="yes" />

Expand Down

0 comments on commit 04f193e

Please sign in to comment.