This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from matteoparlato/working
Working
- Loading branch information
Showing
5 changed files
with
76 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Stop execution when an error occurs | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Detect if PowerShell has administrator privileges | ||
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) | ||
{ | ||
# Run the script with PowerShell with administrator privileges | ||
$Script = $MyInvocation.MyCommand.Definition | ||
$Ps = Join-Path $PSHome 'powershell.exe' | ||
Start-Process $Ps -Verb runas -ArgumentList "& '$Script'" | ||
exit(0) | ||
} | ||
else | ||
{ | ||
# Contains the path of regasm.exe | ||
$RegAsmPath = "$($env:Windir)\Microsoft.NET\Framework\v2.0.50727\regasm.exe" | ||
if (-not (Test-Path $RegAsmPath)) | ||
{ | ||
throw "regasm.exe not found in $RegAsmPath" | ||
} | ||
|
||
# Ask for [Install], [Remove] or [Abort] | ||
$Options = [System.Management.Automation.Host.ChoiceDescription[]] @("&Install", "&Remove", "&Abort") | ||
$Selection = $host.UI.PromptForChoice("Installer of OutlookCOMM for NAV Classic", "What do you want to do?", $Options, 0) | ||
if ($Selection -eq 0 -or $Selection -eq 1) | ||
{ | ||
# Create the folder OutlookCOMM in C:\ drive if it does not exists | ||
$TargetFolder = "C:\OutlookCOMM" | ||
if (-not [IO.Directory]::Exists($TargetFolder)) | ||
{ | ||
[IO.Directory]::CreateDirectory($TargetFolder) | Out-Null | ||
} | ||
|
||
# Copy OutlookCOMM files to $TargetFolder | ||
Copy-Item "$PSScriptRoot\OutlookCOMM.COM.dll" -Destination "$TargetFolder" -Force | ||
Copy-Item "$PSScriptRoot\OutlookCOMM.COM.tlb" -Destination "$TargetFolder" -Force | ||
|
||
# Create the [Install] command | ||
$RegAsmArgs = ($("`"$TargetFolder\OutlookCOMM.COM.dll`""), "/tlb:`"$("$TargetFolder\OutlookCOMM.COM.tlb")`"", "/silent", "/codebase") | ||
|
||
# If user selected [Remove] add /u (unregister) parameter (/unregister is not recognised sometimes) | ||
if ($Selection -eq 1) | ||
{ | ||
$RegAsmArgs = @("/u") + $RegAsmArgs | ||
|
||
# Detect if finsql.exe is running (can't unregister until closed) | ||
$FinsqlProcess = Get-Process finsql -ErrorAction SilentlyContinue | ||
if($FinsqlProcess) | ||
{ | ||
throw "Close all finsql.exe instances before removing OutlookCOMM" | ||
} | ||
} | ||
|
||
# Run regasm.exe with passed parameters | ||
& $RegAsmPath @RegAsmArgs | ||
} | ||
exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters