Skip to content

Commit c913d58

Browse files
committed
[DynaLog] Massive improvements (12/29/2024)
1 parent 7d8c0d2 commit c913d58

24 files changed

+493
-216
lines changed

MainForm.vb

+3
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ Public Class MainForm
850850
DynaLog.LogMessage("System Theme : " & Quote & ThemeDll & Quote)
851851
DynaLog.LogMessage("PrePolicy Theme: " & Quote & PrePol & Quote)
852852
If Not ThemeDll.Equals(PrePol, StringComparison.OrdinalIgnoreCase) Then
853+
DynaLog.LogMessage("System Theme and PrePolicy Theme are different.")
853854
DynaLog.LogMessage("A custom theme has been detected. There may be visual issues with DISMTools")
854855
Dim msg As String = ""
855856
Dim titleMsg As String = ""
@@ -889,6 +890,8 @@ Public Class MainForm
889890
msg = "DISMTools ha rilevato che su questo sistema è stato impostato un tema personalizzato. Alcuni temi personalizzati fanno sì che il programma non abbia un aspetto corretto, quindi si consiglia di passare al tema predefinito."
890891
End Select
891892
MsgBox(msg, vbOKOnly + vbExclamation, titleMsg)
893+
Else
894+
DynaLog.LogMessage("System Theme and PrePolicy Theme are the same.")
892895
End If
893896
Catch ex As Exception
894897

Panels/ISOFiles/ISOCreator.vb

+40-9
Original file line numberDiff line numberDiff line change
@@ -370,38 +370,50 @@ Public Class ISOCreator
370370
End Sub
371371

372372
Private Sub OpenFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
373+
DynaLog.LogMessage("Source image file to test: " & Quote & OpenFileDialog1.FileName & Quote)
373374
TextBox1.Text = OpenFileDialog1.FileName
374375
End Sub
375376

376377
Sub GetImageInfo(ImageFile As String)
378+
DynaLog.LogMessage("Image file to get information about: " & Quote & ImageFile & Quote)
379+
DynaLog.LogMessage("Checking if mounted image detector is busy...")
377380
ListView1.Items.Clear()
378381
If MainForm.MountedImageDetectorBW.IsBusy Then
382+
DynaLog.LogMessage("Mounted image detector is busy. Stopping it...")
379383
MainForm.MountedImageDetectorBWRestarterTimer.Enabled = False
380384
MainForm.MountedImageDetectorBW.CancelAsync()
381385
While MainForm.MountedImageDetectorBW.IsBusy
382386
Application.DoEvents()
383387
Thread.Sleep(500)
384388
End While
385389
End If
390+
DynaLog.LogMessage("Checking if image status watchers are busy...")
386391
MainForm.WatcherTimer.Enabled = False
392+
DynaLog.LogMessage("Image status watchers might be busy. Stopping them if they are...")
387393
If MainForm.WatcherBW.IsBusy Then MainForm.WatcherBW.CancelAsync()
388394
While MainForm.WatcherBW.IsBusy
389395
Application.DoEvents()
390396
Thread.Sleep(100)
391397
End While
392398
Try
399+
DynaLog.LogMessage("Initializing API...")
393400
DismApi.Initialize(DismLogLevel.LogErrors)
394401
ImageInfoCollection = DismApi.GetImageInfo(ImageFile)
395-
For Each ImageInfo As DismImageInfo In ImageInfoCollection
396-
ListView1.Items.Add(New ListViewItem(New String() {
397-
(ImageInfoCollection.IndexOf(ImageInfo) + 1),
398-
ImageInfo.ImageName,
399-
ImageInfo.ImageDescription,
400-
ImageInfo.ProductVersion.ToString(),
401-
Casters.CastDismArchitecture(ImageInfo.Architecture)
402-
}))
403-
Next
402+
DynaLog.LogMessage("Information collection count: " & ImageInfoCollection.Count)
403+
If ImageInfoCollection.Count > 0 Then
404+
DynaLog.LogMessage("This file has images. Updating lists...")
405+
For Each ImageInfo As DismImageInfo In ImageInfoCollection
406+
ListView1.Items.Add(New ListViewItem(New String() {
407+
(ImageInfoCollection.IndexOf(ImageInfo) + 1),
408+
ImageInfo.ImageName,
409+
ImageInfo.ImageDescription,
410+
ImageInfo.ProductVersion.ToString(),
411+
Casters.CastDismArchitecture(ImageInfo.Architecture)
412+
}))
413+
Next
414+
End If
404415
Catch ex As Exception
416+
DynaLog.LogMessage("Could not get image file information. Error message: " & ex.Message)
405417
Dim msg As String = ""
406418
Select Case MainForm.Language
407419
Case 0
@@ -430,20 +442,26 @@ Public Class ISOCreator
430442
End Select
431443
MsgBox(msg, vbOKOnly + vbCritical, Label1.Text)
432444
Finally
445+
DynaLog.LogMessage("Shutting down API...")
433446
Try
434447
DismApi.Shutdown()
435448
Catch ex As Exception
436449
' Don't do anything
437450
End Try
438451
End Try
452+
DynaLog.LogMessage("This process has finished.")
439453
Call MainForm.MountedImageDetectorBW.RunWorkerAsync()
440454
End Sub
441455

442456
Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
457+
DynaLog.LogMessage("Specified destination: " & Quote & SaveFileDialog1.FileName & Quote)
443458
TextBox3.Text = SaveFileDialog1.FileName
444459
End Sub
445460

446461
Private Sub OK_Button_Click(sender As Object, e As EventArgs) Handles OK_Button.Click
462+
DynaLog.LogMessage("Checking provided information...")
463+
DynaLog.LogMessage("- Source image to add to ISO file: " & Quote & TextBox1.Text & Quote)
464+
DynaLog.LogMessage("- Destination ISO file: " & Quote & TextBox3.Text & Quote)
447465
If TextBox1.Text = "" OrElse Not File.Exists(TextBox1.Text) Then
448466
Select Case MainForm.Language
449467
Case 0
@@ -574,12 +592,19 @@ Public Class ISOCreator
574592

575593
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
576594
BackgroundWorker1.ReportProgress(0)
595+
DynaLog.LogMessage("Starting PE Helper...")
596+
DynaLog.LogMessage("- Task: generate ISO")
597+
DynaLog.LogMessage("- Architecture: " & ComboBox1.SelectedItem)
598+
DynaLog.LogMessage("- Image file to test: " & Quote & TextBox1.Text & Quote)
599+
DynaLog.LogMessage("- Unattended answer file to try: " & Quote & TextBox4.Text & Quote)
600+
DynaLog.LogMessage("- Destination ISO file: " & Quote & TextBox3.Text & Quote)
577601
Dim ISOCreator As New Process()
578602
ISOCreator.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) & "\system32\WindowsPowerShell\v1.0\powershell.exe"
579603
ISOCreator.StartInfo.WorkingDirectory = Application.StartupPath & "\bin\extps1\PE_Helper"
580604
ISOCreator.StartInfo.Arguments = "-noprofile -nologo -executionpolicy unrestricted -file " & Quote & Application.StartupPath & "\bin\extps1\PE_Helper\PE_Helper.ps1" & Quote & " -cmd StartPEGen -arch " & ComboBox1.SelectedItem & " -imgFile " & Quote & TextBox1.Text & Quote & " -isoPath " & Quote & TextBox3.Text & Quote & " -unattendFile " & Quote & TextBox4.Text & Quote
581605
ISOCreator.Start()
582606
ISOCreator.WaitForExit()
607+
DynaLog.LogMessage("The PE Helper process finished with exit code " & Hex(ISOCreator.ExitCode))
583608
success = (ISOCreator.ExitCode = 0)
584609
BackgroundWorker1.ReportProgress(100)
585610
End Sub
@@ -600,6 +625,8 @@ Public Class ISOCreator
600625
End Sub
601626

602627
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
628+
DynaLog.LogMessage("The PE Helper has finished.")
629+
DynaLog.LogMessage("- Did it succeed? " & If(success, "Yes", "No"))
603630
Dim msg As String = ""
604631
Select Case MainForm.Language
605632
Case 0
@@ -636,6 +663,7 @@ Public Class ISOCreator
636663

637664
Private Sub ISOCreator_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
638665
If BackgroundWorker1.IsBusy Then
666+
DynaLog.LogMessage("The PE Helper is busy. Cancelling exit...")
639667
e.Cancel = True
640668
Beep()
641669
End If
@@ -644,12 +672,14 @@ Public Class ISOCreator
644672
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
645673
PopupImageManager.Location = Button2.PointToScreen(Point.Empty)
646674
If PopupImageManager.ShowDialog() = DialogResult.OK Then
675+
DynaLog.LogMessage("Selected image: " & PopupImageManager.selectedImgFile)
647676
TextBox1.Text = PopupImageManager.selectedImgFile
648677
End If
649678
End Sub
650679

651680
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
652681
If TextBox1.Text <> "" And File.Exists(TextBox1.Text) Then
682+
DynaLog.LogMessage("The specified file exists. Getting information...")
653683
GetImageInfo(TextBox1.Text)
654684
End If
655685
End Sub
@@ -699,6 +729,7 @@ Public Class ISOCreator
699729
End Sub
700730

701731
Private Sub OpenFileDialog2_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk
732+
DynaLog.LogMessage("Unattended answer file to test: " & Quote & OpenFileDialog2.FileName & Quote)
702733
TextBox4.Text = OpenFileDialog2.FileName
703734
End Sub
704735

Panels/ISOFiles/NewTestingEnv.vb

+8
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ Public Class NewTestingEnv
229229

230230
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
231231
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
232+
DynaLog.LogMessage("Target location of testing environment files: " & Quote & FolderBrowserDialog1.SelectedPath & Quote)
232233
TextBox3.Text = FolderBrowserDialog1.SelectedPath
233234
End If
234235
End Sub
@@ -274,12 +275,17 @@ Public Class NewTestingEnv
274275

275276
Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
276277
BackgroundWorker1.ReportProgress(0)
278+
DynaLog.LogMessage("Starting PE Helper...")
279+
DynaLog.LogMessage("- Task: generate testing environment")
280+
DynaLog.LogMessage("- Architecture: " & ComboBox1.SelectedItem)
281+
DynaLog.LogMessage("- Destination folder for testing environment: " & Quote & TextBox3.Text & Quote)
277282
Dim ISOCreator As New Process()
278283
ISOCreator.StartInfo.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Windows) & "\system32\WindowsPowerShell\v1.0\powershell.exe"
279284
ISOCreator.StartInfo.WorkingDirectory = Application.StartupPath & "\bin\extps1\PE_Helper"
280285
ISOCreator.StartInfo.Arguments = "-noprofile -nologo -executionpolicy unrestricted -file " & Quote & Application.StartupPath & "\bin\extps1\PE_Helper\PE_Helper.ps1" & Quote & " -cmd StartDevelopment -testArch " & ComboBox1.SelectedItem & " -targetPath " & Quote & TextBox3.Text & Quote
281286
ISOCreator.Start()
282287
ISOCreator.WaitForExit()
288+
DynaLog.LogMessage("The PE Helper process finished with exit code " & Hex(ISOCreator.ExitCode))
283289
success = (ISOCreator.ExitCode = 0)
284290
BackgroundWorker1.ReportProgress(100)
285291
End Sub
@@ -298,6 +304,8 @@ Public Class NewTestingEnv
298304
End Sub
299305

300306
Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
307+
DynaLog.LogMessage("The PE Helper has finished.")
308+
DynaLog.LogMessage("- Did it succeed? " & If(success, "Yes", "No"))
301309
Dim msg As String = ""
302310
Select Case MainForm.Language
303311
Case 0

Panels/Img_Ops/ApplicationDriveSpecifier.vb

+3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ Public Class ApplicationDriveSpecifier
2020
End Sub
2121

2222
Sub ListDisks()
23+
DynaLog.LogMessage("Preparing to list disks...")
2324
ListView1.Items.Clear()
2425
Dim searcher As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT DeviceID, Model, Partitions, Size FROM Win32_DiskDrive")
2526
Dim dskResults As ManagementObjectCollection = searcher.Get()
27+
DynaLog.LogMessage("Management object searcher returned " & dskResults.Count & " result(s)")
2628
For Each result As ManagementObject In dskResults
2729
ListView1.Items.Add(New ListViewItem(New String() {result("DeviceID"), result("Model"), result("Partitions"), result("Size") & " (~" & Converters.BytesToReadableSize(result("Size")) & ")"}))
2830
Next
@@ -156,6 +158,7 @@ Public Class ApplicationDriveSpecifier
156158
End Sub
157159

158160
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
161+
DynaLog.LogMessage("Refreshing lists...")
159162
ListDisks()
160163
End Sub
161164

Panels/Img_Ops/ImgAppend.vb

+28
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ Public Class ImgAppend
77

88
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
99
Dim msg As String = ""
10+
DynaLog.LogMessage("Disposing of progress panel if not disposed of previously...")
1011
If Not ProgressPanel.IsDisposed Then ProgressPanel.Dispose()
12+
DynaLog.LogMessage("Checking source image directory...")
1113
If TextBox1.Text = "" Or Not Directory.Exists(TextBox1.Text) Then
14+
DynaLog.LogMessage("Either no source directory has been specified or it does not exist in the file system.")
1215
Select Case MainForm.Language
1316
Case 0
1417
Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName
@@ -39,7 +42,9 @@ Public Class ImgAppend
3942
Else
4043
ProgressPanel.AppendixSourceDir = TextBox1.Text
4144
End If
45+
DynaLog.LogMessage("Checking destination image...")
4246
If TextBox2.Text = "" Or Not File.Exists(TextBox2.Text) Then
47+
DynaLog.LogMessage("Either no destination image has been specified or it does not exist in the file system.")
4348
Select Case MainForm.Language
4449
Case 0
4550
Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName
@@ -70,7 +75,9 @@ Public Class ImgAppend
7075
Else
7176
ProgressPanel.AppendixDestinationImage = TextBox2.Text
7277
End If
78+
DynaLog.LogMessage("Checking name of image to append to destination...")
7379
If TextBox3.Text = "" Then
80+
DynaLog.LogMessage("No name has been specified.")
7481
Select Case MainForm.Language
7582
Case 0
7683
Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName
@@ -103,9 +110,13 @@ Public Class ImgAppend
103110
End If
104111
ProgressPanel.AppendixDescription = TextBox4.Text
105112
If CheckBox1.Checked Then
113+
DynaLog.LogMessage("A configuration list file is expected to be used. Checking specified file...")
106114
If TextBox5.Text <> "" And File.Exists(TextBox5.Text) Then
115+
DynaLog.LogMessage("A configuration list file has been specified and it exists in the file system.")
107116
ProgressPanel.AppendixWimScriptConfig = TextBox5.Text
108117
Else
118+
DynaLog.LogMessage("Either no configuration list file has been specified or it does not exist in the file system.")
119+
DynaLog.LogMessage("We can continue without it, but that may not be what the user wants. Asking...")
109120
Select Case MainForm.Language
110121
Case 0
111122
Select Case My.Computer.Info.InstalledUICulture.ThreeLetterWindowsLanguageName
@@ -132,12 +143,15 @@ Public Class ImgAppend
132143
msg = "Non è stato specificato alcun file dell'elenco di configurazione oppure non è stato possibile rilevare il file dell'elenco di configurazione nel file system. Si desidera continuare senza alcun file dell'elenco di configurazione?"
133144
End Select
134145
If MsgBox(msg, vbYesNo + vbCritical, Label1.Text) = MsgBoxResult.Ok Then
146+
DynaLog.LogMessage("The user does not mind if we continue without the configuration list file.")
135147
ProgressPanel.AppendixWimScriptConfig = ""
136148
Else
149+
DynaLog.LogMessage("The user wants the configuration list file.")
137150
Exit Sub
138151
End If
139152
End If
140153
Else
154+
DynaLog.LogMessage("A configuration list file is not expected to be used.")
141155
ProgressPanel.AppendixWimScriptConfig = ""
142156
End If
143157
ProgressPanel.AppendixUseWimBoot = CheckBox2.Checked
@@ -442,6 +456,7 @@ Public Class ImgAppend
442456

443457
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
444458
If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
459+
DynaLog.LogMessage("Selected source directory: " & Quote & FolderBrowserDialog1.SelectedPath & Quote)
445460
TextBox1.Text = FolderBrowserDialog1.SelectedPath
446461
End If
447462
End Sub
@@ -451,6 +466,7 @@ Public Class ImgAppend
451466
End Sub
452467

453468
Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
469+
DynaLog.LogMessage("Selected destination image file: " & Quote & SaveFileDialog1.FileName & Quote)
454470
TextBox2.Text = SaveFileDialog1.FileName
455471
End Sub
456472

@@ -489,34 +505,46 @@ Public Class ImgAppend
489505
End Sub
490506

491507
Function GetLastImageName() As String
508+
DynaLog.LogMessage("Image file to get information about: " & Quote & TextBox2.Text & Quote)
492509
Dim imageName As String = ""
493510
Try
511+
DynaLog.LogMessage("Initializing API...")
494512
DismApi.Initialize(DismLogLevel.LogErrors)
495513
Dim ImageInfoCollection As DismImageInfoCollection = DismApi.GetImageInfo(TextBox2.Text)
514+
DynaLog.LogMessage("Information collection count: " & ImageInfoCollection.Count)
515+
DynaLog.LogMessage("Getting name of last index...")
496516
imageName = ImageInfoCollection.Last.ImageName
497517
Catch ex As Exception
518+
DynaLog.LogMessage("Could not get image file information. Error message: " & ex.Message)
498519
MsgBox("Could not grab last image name. Error information:" & CrLf & CrLf & ex.ToString(), vbOKOnly + vbCritical, Label1.Text)
499520
Finally
500521
Try
522+
DynaLog.LogMessage("Shutting down API...")
501523
DismApi.Shutdown()
502524
Catch ex As Exception
503525
' Don't do anything
504526
End Try
505527
End Try
528+
DynaLog.LogMessage("Name of last image: " & imageName)
506529
Return imageName
507530
End Function
508531

509532
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
533+
DynaLog.LogMessage("Checking if the destination file has been specified and exists...")
510534
If TextBox2.Text = "" OrElse Not File.Exists(TextBox2.Text) Then Exit Sub
535+
DynaLog.LogMessage("Checking if mounted image detector is busy...")
511536
If MainForm.MountedImageDetectorBW.IsBusy Then
537+
DynaLog.LogMessage("Mounted image detector is busy. Stopping it...")
512538
MainForm.MountedImageDetectorBWRestarterTimer.Enabled = False
513539
MainForm.MountedImageDetectorBW.CancelAsync()
514540
While MainForm.MountedImageDetectorBW.IsBusy
515541
Application.DoEvents()
516542
Threading.Thread.Sleep(500)
517543
End While
518544
End If
545+
DynaLog.LogMessage("Checking if image status watchers are busy...")
519546
MainForm.WatcherTimer.Enabled = False
547+
DynaLog.LogMessage("Image status watchers might be busy. Stopping them if they are...")
520548
If MainForm.WatcherBW.IsBusy Then MainForm.WatcherBW.CancelAsync()
521549
While MainForm.WatcherBW.IsBusy
522550
Application.DoEvents()

0 commit comments

Comments
 (0)