Imports System.IO Imports System.CodeDom.Compiler ' ------------------------------------- ' Support routines for the wizard form ' ------------------------------------- Public Module wizardSupport Public Enum PXEBootTask 'Types of media PXE_Boot_Floppy PXE_Boot_CD End Enum Public PXEBootType As PXEBootTask ' Startup mode for wizard, as defined in WizardTask Dim response As MsgBoxResult Dim msg As String Dim title As String Dim style As MsgBoxStyle Public Sub PXEBoot() If PXEBootType = PXEBootTask.PXE_Boot_Floppy Then 'create a PXE Floppy Dim response As MsgBoxResult msg = "Creates a floppy that can be used on computers that do not have support for PXE boot in BIOS. Please insert a blank floppy disk in drive A:" ' Define message. style = MsgBoxStyle.OkCancel title = "Create a PXE boot floppy" ' Define title. response = MsgBox(msg, style, title) If response = MsgBoxResult.Ok Then ' User chose OK. Shell(Globals.strAppdir + "\diskwrite\DiskWrite.exe " + Globals.strAppdir + "\data\netboot.img", AppWinStyle.NormalFocus, False) End If ElseIf PXEBootType = PXEBootTask.PXE_Boot_CD Then 'Create a PXE boot CD Dim isoName As String msg = "Creates a CD-image that can be used to create a PXE BOOT-CD for computers that do not have support for PXE boot in BIOS." ' Define message. style = MsgBoxStyle.OkCancel title = "Create a PXE boot CD" ' Define title. response = MsgBox(msg, style, title) If response = MsgBoxResult.Ok Then ' User chose OK. Dim objDialog As New SaveFileDialog isoName = "Netboot" objDialog.Filter = "CD-R ISO images (*.iso)|*.iso" objDialog.DefaultExt = "iso" objDialog.FileName = isoName If objDialog.ShowDialog() = DialogResult.OK Then isoName = objDialog.FileName End If File.Copy(Globals.strAppdir + "\data\netboot.iso", isoName, True) End If End If End Sub ' Does a look-up in the file strFile on the line numbered by intIndex (zero based), then skips the first parameter on the line, ' and interprets all the following parameters on the row as files to be copied from strSourcePath to strDestPath Sub CopyFiles(ByVal strDriver As String, ByVal strFile As String, ByVal strSourcePath As String, ByVal strDestPath As String, ByVal objTempRoot As TempFileCollection) Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile) MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(";") Dim intRow As Integer Dim currentRow As String() ReDim currentRow(1) 'Initialise so that we can run the loop below first time. 'Read rows until we found the row While Not MyReader.EndOfData AndAlso currentRow(1) <> strDriver Try currentRow = MyReader.ReadFields() Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.") End Try intRow = intRow + 1 End While ' We have found the right row Dim i As Integer For i = 2 To currentRow.GetUpperBound(0) File.Copy(strSourcePath & "\" & currentRow(i), strDestPath + "\" + currentRow(i), True) Try objTempRoot.AddFile(strDestPath + "\" + currentRow(i), False) Catch End Try Next End Using End Sub ' Copies all files specified in strFile from strSourcePath to strDestPath. ' The first paramter on each line is skipped the following parameters on the line is iterpreted as file names Sub CopyAllFiles(ByVal strFile As String, ByVal strSourcePath As String, ByVal strDestPath As String, ByVal objTempRoot As TempFileCollection) Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile) MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(";") Dim intRow As Integer Dim currentRow As String() While Not MyReader.EndOfData Try currentRow = MyReader.ReadFields() Dim i As Integer For i = 2 To currentRow.GetUpperBound(0) If Not File.Exists(strDestPath + "\" + currentRow(i)) Then File.Copy(strSourcePath & "\" & currentRow(i), strDestPath + "\" + currentRow(i), True) Try objTempRoot.AddFile(strDestPath + "\" + currentRow(i), False) Catch End Try End If Next Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.") End Try intRow = intRow + 1 End While End Using End Sub ' Does a look-up in the file strFile on the line numbered by intIndex (zero based), and returns the name of the first file specified on that line. Function LookupFile(ByVal intIndex As Integer, ByVal strFile As String) As String Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile) MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(";") Dim intRow As Integer Dim currentRow As String() While Not MyReader.EndOfData AndAlso intRow < intIndex Try currentRow = MyReader.ReadFields() Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.") End Try intRow = intRow + 1 End While Try currentRow = MyReader.ReadFields() Return currentRow(1) Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.") Return "" End Try End Using End Function Public Sub AnywhereTSHomepage() '**************************************************** '* Denna metod opens the AnywhereTS homepage * '**************************************************** On Error GoTo useie 'Try letting system select browser System.Diagnostics.Process.Start("http://anywhereTS.com") On Error GoTo -1 Return useie: On Error GoTo -1 'Failed, use IE System.Diagnostics.Process.Start("IExplore.exe", "http://anywhereTS.com") End Sub Public Function IsValidIPAddress(ByVal strIPAddress As String) As Boolean On Error GoTo Handler Dim varAddress As Object, n As Long, lCount As Long varAddress = Split(strIPAddress, ".", , vbTextCompare) '// If IsArray(varAddress) Then For n = LBound(varAddress) To UBound(varAddress) lCount = lCount + 1 varAddress(n) = CByte(varAddress(n)) Next '// IsValidIPAddress = (lCount = 4) End If '// Handler: End Function Public Sub LoadComboBoxFromFile(ByRef cboList As ComboBox, ByVal strFile As String) cboList.Items.Clear() Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(strFile) MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(";") Dim currentRow As String() While Not MyReader.EndOfData Try currentRow = MyReader.ReadFields() cboList.Items.Add(currentRow(0)) Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException MsgBox("Error in file " & strFile & ", line: '" & ex.Message & "'is not valid and will be skipped.") End Try End While End Using cboList.SelectedIndex = 0 End Sub End Module