Initialer Import der Synology Scripts
This commit is contained in:
Executable
+112
@@ -0,0 +1,112 @@
|
||||
<#
|
||||
.NOTES
|
||||
===========================================================================
|
||||
FileName: tst.ps1
|
||||
Author: micha
|
||||
Created On: 2024.04.26
|
||||
Last Updated: 2024.04.26
|
||||
Organization:
|
||||
Version: v0.1
|
||||
===========================================================================
|
||||
|
||||
.DESCRIPTION
|
||||
|
||||
.DEPENDENCIES
|
||||
#>
|
||||
|
||||
# ScriptBlock to Execute in STA Runspace
|
||||
$sbGUI = {
|
||||
param($BaseDir)
|
||||
|
||||
#region Child Forms
|
||||
|
||||
$Script:childFormInfo = @{
|
||||
'MainForm' = @{
|
||||
XMLText = @"
|
||||
<Form Name="MainForm" Size="2714; 988">
|
||||
<Label Name="lbl_Programs" Font="Segoe UI; 18pt" Location="0; 10" Size="200; 50" TextAlign="MiddleCenter" Text="Install Options" />
|
||||
<Label Name="lbl_config" Font="Segoe UI; 18pt" Location="500; 10" Size="260; 50" TextAlign="MiddleCenter" Text="Configuration Options" />
|
||||
<Label Name="lbl_symantec" Font="Segoe UI; 18pt" Location="0; 100" Size="150; 30" TextAlign="MiddleCenter" Text="Symantec" />
|
||||
<Label Name="lbl_Packages" Location="0; 140" TextAlign="MiddleCenter" Text="Packages" />
|
||||
</Form>
|
||||
"@
|
||||
}
|
||||
|
||||
#endregion Child Forms
|
||||
|
||||
#region Dot Sourcing of files
|
||||
|
||||
$dotSourceDir = $BaseDir
|
||||
|
||||
. "$($dotSourceDir)\Functions.ps1"
|
||||
. "$($dotSourceDir)\EnvSetup.ps1"
|
||||
|
||||
#endregion Dot Sourcing of files
|
||||
|
||||
#region Form Initialization
|
||||
|
||||
try {
|
||||
ConvertFrom-WinFormsXML -Reference refs -Suppress -Xml @"
|
||||
<Form Name="MainForm" />
|
||||
"@
|
||||
} catch {Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered during Form Initialization."}
|
||||
|
||||
#endregion Form Initialization
|
||||
|
||||
#region Other Actions Before ShowDialog
|
||||
|
||||
try {
|
||||
Remove-Variable -Name eventSB
|
||||
} catch {Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered before ShowDialog."}
|
||||
|
||||
#endregion Other Actions Before ShowDialog
|
||||
|
||||
# Show the form
|
||||
try {[void]$Script:refs['MainForm'].ShowDialog()} catch {Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered unexpectedly at ShowDialog."}
|
||||
|
||||
<#
|
||||
#region Actions After Form Closed
|
||||
|
||||
try {
|
||||
|
||||
} catch {Update-ErrorLog -ErrorRecord $_ -Message "Exception encountered after Form close."}
|
||||
|
||||
#endregion Actions After Form Closed
|
||||
#>
|
||||
}
|
||||
|
||||
#region Start Point of Execution
|
||||
|
||||
# Initialize STA Runspace
|
||||
$rsGUI = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
|
||||
$rsGUI.ApartmentState = 'STA'
|
||||
$rsGUI.ThreadOptions = 'ReuseThread'
|
||||
$rsGUI.Open()
|
||||
|
||||
# Create the PSCommand, Load into Runspace, and BeginInvoke
|
||||
$cmdGUI = [Management.Automation.PowerShell]::Create().AddScript($sbGUI).AddParameter('BaseDir',$PSScriptRoot)
|
||||
$cmdGUI.RunSpace = $rsGUI
|
||||
$handleGUI = $cmdGUI.BeginInvoke()
|
||||
|
||||
# Hide Console Window
|
||||
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
||||
[DllImport("Kernel32.dll")]
|
||||
public static extern IntPtr GetConsoleWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
||||
'
|
||||
|
||||
[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0)
|
||||
|
||||
#Loop Until GUI Closure
|
||||
while ( $handleGUI.IsCompleted -eq $false ) {Start-Sleep -Seconds 5}
|
||||
|
||||
# Dispose of GUI Runspace/Command
|
||||
$cmdGUI.EndInvoke($handleGUI)
|
||||
$cmdGUI.Dispose()
|
||||
$rsGUI.Dispose()
|
||||
|
||||
Exit
|
||||
|
||||
#endregion Start Point of Execution
|
||||
Reference in New Issue
Block a user