1
+ $t = ' [DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
2
+ add-type - name win - member $t - namespace native
3
+ [native.win ]::ShowWindow(([System.Diagnostics.Process ]::GetCurrentProcess() | Get-Process ).MainWindowHandle, 0 ) # by Andy Lowry found at : https://stackoverflow.com/questions/1802127/how-to-run-a-powershell-script-without-displaying-a-window
4
+
1
5
# Enable debugging
2
6
# Set-PSDebug -Trace 1
3
7
@@ -45,7 +49,7 @@ if (! $myWindowsPrincipal.IsInRole($adminRole))
45
49
Add-Type - assembly System.Windows.Forms
46
50
Add-Type - assembly System.Drawing
47
51
48
- # Fonction pour ajouter des logs
52
+ # Log function
49
53
function Add-Log {
50
54
param (
51
55
[string ]$message
@@ -58,7 +62,7 @@ function Add-Log {
58
62
# Main Form
59
63
$main_form = New-Object System.Windows.Forms.Form
60
64
$main_form.Text = ' Tiny11makerGUI'
61
- $main_form.Width = 600
65
+ $main_form.Width = 485
62
66
$main_form.Height = 450
63
67
$main_form.StartPosition = ' CenterScreen'
64
68
@@ -80,14 +84,14 @@ $TitleLabel.Location = New-Object System.Drawing.Point(
80
84
# ISO Selection TextBox
81
85
$IsoTextBox = New-Object System.Windows.Forms.TextBox
82
86
$IsoTextBox.Text = " Select an .iso to mount"
83
- $IsoTextBox.Width = 360
87
+ $IsoTextBox.Width = 250
84
88
$IsoTextBox.Location = New-Object System.Drawing.Point(20 , 65 )
85
89
$IsoTextBox.Enabled = $false
86
90
87
91
# Choose Button
88
92
$ChooseButton = New-Object System.Windows.Forms.Button
89
93
$ChooseButton.Text = " Choose"
90
- $ChooseButton.Location = New-Object System.Drawing.Point(400 , 60 )
94
+ $ChooseButton.Location = New-Object System.Drawing.Point(280 , 60 )
91
95
$ChooseButton.Size = New-Object System.Drawing.Size(80 , 30 )
92
96
$ChooseButton.Add_Click ({
93
97
# Placeholder logic to simulate file selection
@@ -103,11 +107,13 @@ $ChooseButton.Add_Click({
103
107
# Mount Button
104
108
$MountButton = New-Object System.Windows.Forms.Button
105
109
$MountButton.Text = " Mount"
106
- $MountButton.Location = New-Object System.Drawing.Point(490 , 60 )
110
+ $MountButton.Location = New-Object System.Drawing.Point(370 , 60 )
107
111
$MountButton.Size = New-Object System.Drawing.Size(80 , 30 )
108
112
$MountButton.Enabled = $false
109
113
$MountButton.Add_Click ({
110
114
Add-Log " Mounting: $ ( $IsoTextBox.Text ) "
115
+ $ChooseButton.Enabled = $false
116
+ $MountButton.Enabled = $false
111
117
112
118
try {
113
119
Mount-DiskImage - ImagePath $IsoTextBox.Text
@@ -140,32 +146,34 @@ $DriveLabel.Enabled = $false
140
146
141
147
# Drive Letter ComboBox
142
148
$DriveComboBox = New-Object System.Windows.Forms.ComboBox
143
- $DriveComboBox.Width = 150
149
+ $DriveComboBox.Width = 120
144
150
$DriveComboBox.Location = New-Object System.Drawing.Point(20 , 135 )
145
151
$DriveComboBox.Enabled = $false
146
152
147
153
# SKU Index Label
148
154
$ImageIndexLabel = New-Object System.Windows.Forms.Label
149
155
$ImageIndexLabel.Text = " SKU:"
150
156
$ImageIndexLabel.Font = New-Object System.Drawing.Font(' Consolas' , 10 )
151
- $ImageIndexLabel.Location = New-Object System.Drawing.Point(200 , 110 )
157
+ $ImageIndexLabel.Location = New-Object System.Drawing.Point(150 , 110 )
152
158
$ImageIndexLabel.AutoSize = $true
153
- $ImageIndexLabel.Enabled = $false
159
+ $ImageIndexLabel.Enabled = $false
154
160
155
161
# SKU Index ComboBox
156
162
$ImageIndexComboBox = New-Object System.Windows.Forms.ComboBox
157
- $ImageIndexComboBox.Width = 150
158
- $ImageIndexComboBox.Location = New-Object System.Drawing.Point(200 , 135 )
163
+ $ImageIndexComboBox.Width = 120
164
+ $ImageIndexComboBox.Location = New-Object System.Drawing.Point(150 , 135 )
159
165
$ImageIndexComboBox.Enabled = $false
160
166
161
167
# Start Button
162
168
$StartButton = New-Object System.Windows.Forms.Button
163
169
$StartButton.Text = " Start"
164
- $StartButton.Location = New-Object System.Drawing.Point(400 , 135 )
170
+ $StartButton.Location = New-Object System.Drawing.Point(280 , 130 )
165
171
$StartButton.Size = New-Object System.Drawing.Size(170 , 30 )
166
172
$StartButton.Enabled = $false
167
173
$StartButton.Add_Click ({
168
174
$StartButton.Enabled = $false
175
+ $DriveComboBox.Enabled = $false
176
+ $DriveLabel.Enabled = $false
169
177
Add-Log " Starting..."
170
178
Add-Log " Drive: $ ( $DriveComboBox.SelectedItem ) "
171
179
Add-Log " Scratch disk: $ScratchDisk "
@@ -208,6 +216,7 @@ Get-WindowsImage -ImagePath $ScratchDisk\tiny11\sources\install.wim
208
216
$ImageIndexComboBox.Items.AddRange ((Get-WindowsImage - ImagePath $ScratchDisk \tiny11\sources\install.wim).ImageIndex)
209
217
$ImageIndexLabel.Enabled = $true
210
218
$ImageIndexComboBox.Enabled = $true
219
+ [System.Windows.Forms.MessageBox ]::Show(" Please select the image under "" SKU"" ." , " Image selection" , [System.Windows.Forms.MessageBoxButtons ]::OK, [System.Windows.Forms.MessageBoxIcon ]::Information)
211
220
Add-Log " Please select the image index in 'SKU'"
212
221
Add-Log ' '
213
222
$ImageIndexComboBox.Add_SelectedIndexChanged ({
@@ -596,6 +605,10 @@ Add-Log "Performing Cleanup..."
596
605
Remove-Item - Path " $ScratchDisk \tiny11" - Recurse - Force | Out-Null
597
606
Remove-Item - Path " $ScratchDisk \scratchdir" - Recurse - Force | Out-Null
598
607
Add-Log " Cleanup complete!"
608
+ Add-Log " Dismount used images..."
609
+ Get-Volume - DriveLetter $DriveComboBox.SelectedItem | Get-DiskImage | Dismount-DiskImage # by 790 at https://rcmtech.wordpress.com/2012/12/07/powershell-mounting-and-dismounting-iso-images-on-windows-server-2012-and-windows-8/
610
+ Add-Log " Dismount complete!"
611
+ Add-Log " All done !"
599
612
})
600
613
})
601
614
@@ -611,7 +624,7 @@ $LogsTextBox = New-Object System.Windows.Forms.TextBox
611
624
$LogsTextBox.Multiline = $true
612
625
$LogsTextBox.ScrollBars = ' Vertical'
613
626
$LogsTextBox.Location = New-Object System.Drawing.Point(20 , 210 )
614
- $LogsTextBox.Width = 550
627
+ $LogsTextBox.Width = 430
615
628
$LogsTextBox.Height = 180
616
629
$LogsTextBox.ReadOnly = $true
617
630
Add-Log " main_form.Controls loaded..."
0 commit comments