-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path70_Invoke-MSHStartupAccelerator.ps1
58 lines (43 loc) · 1.6 KB
/
70_Invoke-MSHStartupAccelerator.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<#
.SYNOPSIS
Invokes MSH startup accelerator.
.DESCRIPTION
Invokes MSH startup accelerator.
.PARAMETER MATLABRoot
(Required) Root folder for MATLAB.
.EXAMPLE
Invoke-MSHStartupAccelerator -MATLABRoot "<MATLAB_ROOT_FOLDER>"
.NOTES
Copyright 2024 The MathWorks Inc.
#>
function Invoke-MSHStartupAccelerator {
param(
[Parameter(Mandatory = $true)]
[string] $MATLABRoot
)
Write-Output 'Starting Invoke-MSHStartupAccelerator...'
$ServiceHostPath = "C:\Program Files\MathWorks\ServiceHost"
$IniFilePath = "$Env:TEMP\mshsa.ini"
$LogFilePath = "$Env:ProgramData\MathWorks\mshsa.log"
# Find all files within the ServiceHostPath directory, and output their full paths to the IniFilePath
if (Test-Path -Path $ServiceHostPath) {
Get-ChildItem -Path $ServiceHostPath -File -Recurse | ForEach-Object {
$_.FullName.Replace("$ServiceHostPath\", "")
} | Out-File -FilePath $IniFilePath -Encoding UTF8 -Force
# Execute the MATLABStartupAccelerator on MSH file list
if ($MATLABRoot -and $?) {
& "$MATLABRoot\bin\win64\MATLABStartupAccelerator.exe" 64 $ServiceHostPath $IniFilePath $LogFilePath
}
}
else {
Write-Output 'ServiceHostPath does not exist.'
}
Write-Output 'Done with Invoke-MSHStartupAccelerator.'
}
try {
Invoke-MSHStartupAccelerator -MATLABRoot $Env:MATLABRoot
}
catch {
$ScriptPath = $MyInvocation.MyCommand.Path
Write-Output "WARNING - An error occurred while running script 'Invoke-MSHStartupAccelerator': $ScriptPath. Error: $_"
}