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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085
| ''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Get the number of formated partition and display partitions info
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FormattedPartitionCount(ByRef mess)
Dim fso, d, i, nbpart
nbpart=0
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
'Checking the number of partition scanning diks letter to C to W
For i=Asc("C") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
If d.DriveType=2 Then
nbpart=nbpart+1
End If
End If
End If
Next
'Display The numbers of partition
If nbpart =0 Then
mess = mess & vbCrLf & StrNoFormattedPartition & vbCrLf
Else
mess = mess & vbCrLf & StrFormattedPartition & vbCrLf
End If
'Scan Hard Drives info from Letter C to Letter W (to avoid to see the WinPE default drive (X:))
' and dsiplay info about partition
For i=Asc("C") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
If d.DriveType=2 Then
mess = mess & StrLetter & d.DriveLetter& vbTab & StrLabel & d.VolumeName & vbTab
mess = mess & StrFileSystem & d.FileSystem & vbTab
mess = mess & CLng(d.Totalsize/1024/1024/1024) & "/" & CLng((d.Totalsize-d.AvailableSpace)/1024/1024/1024) & " GB" & vbCrLf
End If
End If
End If
Next
End Sub
'Search what is the boot device (CDROM or UFD) and what is the letter assigned to it to be able to find the Wim File to deploy
'The existance of the folder : EFI\MICROSOFT\BOOT\FONTS is done to recognize a drive containing WinPE
'This fucntion is called only ont time at the startup of the program
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub FindBootDevice ()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim fso, d,i
Dim cdromfound
cdromfound=0
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
'Scanning first if the OS is WinPE checking if the X drive does exist
If Not fso.DriveExists("X") Then Exit Sub
'Scanning CDROMs and UDF
For i=Asc("D") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
' Checking CDROMs & DVDROMs
If d.DriveType=4 Then
If fso.FolderExists(d.DriveLetter& ":\EFI\MICROSOFT\BOOT\FONTS") Then
BOOTDIR=d.DriveLetter & ":\"
BOOTFROM=1
' The machine is booted from WinPE then tools directory in on the X:\tools
TOOLSDIR="X:\tools\"
' Computing the size of the data in MB on the DVD.
' In case of transfer to an UFD this size will be the
' minimum size requetstd of the UFD
DVDSIZE=Round ((d.Totalsize-d.AvailableSpace)/1024/1024,0)
' Exit function, no need to scan UFDs . To avoid
' confusion when an UFD copied from the DVD is
' still connected to the machine
Exit Sub
End If
End If
' Checking UFD
If d.DriveType=1 Then
If fso.FolderExists(d.DriveLetter& ":\EFI\MICROSOFT\BOOT\FONTS") Then
BOOTDIR=d.DriveLetter & ":\"
BOOTFROM=2
' The machine is booted from WinPE then tools directory in on the X:\tools
TOOLSDIR="X:\tools\"
End If
End If
End If
End If
Next
'This is necessary to manage WDS Server scenarios
If BOOTFROM=0 and fso.FolderExists("X:\tools") Then
TOOLSDIR="X:\tools\"
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Getting CDROM information to be displayed on System properties
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DisplayCDROMInfo (ByRef mess)
Dim fso, d,i
Dim cdromfound
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
cdromfound=0
For i= Asc("D") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
' Searching CDROM only
If d.DriveType=4 Then
If cdromfound=0 Then
cdromfound=1
mess = mess & vbCrLf & StrCDROM & vbCrLf
End If
mess = mess & StrLetter & d.DriveLetter& vbTab & StrLabel & d.VolumeName & vbCrLf
End If
End If
End If
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Check if a drive is a network drive and replace its name with the full link
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetNetworkDrivePath (DriveLetter)
Dim Wshnet, MapDrives, i
Set Wshnet=WScript.CreateObject("WScript.Network")
Set MapDrives=Wshnet.EnumNetworkDrives
' No network drive found
If MapDrives.Count = 0 Then
GetNetworkDrivePath=DriveLetter
Exit Function
End If
For i=0 To MapDrives.Count - 1 Step 2
If MapDrives.Item(i)&"\" = DriveLetter Then
GetNetworkDrivePath=MapDrives.Item(i+1)&"\"
Exit Function
End If
Next
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Display Network drives information
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This Function scans the network drives currently connected
'to the machine
Sub DisplayNetworkDrives (ByRef mess)
Dim Wshnet, MapDrives, i
Set Wshnet=WScript.CreateObject("WScript.Network")
Set MapDrives=Wshnet.EnumNetworkDrives
' No network drive found
If MapDrives.Count = 0 Then
mess = mess & vbCrLf & StrNoNetDisk & vbCrLf
Exit Sub
End If
DRVMAPPED=True
mess = mess & vbCrLf & StrNetDisk & vbCrLf
For i=0 To MapDrives.Count - 1 Step 2
mess= mess & MapDrives.Item(i)& vbTab
mess= mess & MapDrives.Item(i+1) & vbCrLf
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Map Network drives using info from networkdisk.txt
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub MapNetworkDrives()
Dim fso,f,ReadTextFile
Dim value
Dim Path,Username,Password
Dim Wshnet
' Try to Map only if previus tentative was not successfull
If DRVMAPPED Then Exit Sub
Set fso = CreateObject("Scripting.FileSystemObject")
' Check if the networkdisk.txt does exist in : '
' -first in the root directory of WinPE and secondely '
' -secondly in the tools directory '
If Not fso.FileExists(BOOTDIR & "networkdisk.txt") And Not fso.FileExists(TOOLSDIR & "networkdisk.txt") Then
mess = mess & Vbvrlf & StrNoNetDisk & vbCrLf
Exit Sub
End If
' Read each line of the file
' The file should be in the folowing order
' <PATH>\\server\myimages </PATH>
' <USERNAME>MyUsername</USERNAME>
' <PASSWORD>MyPassword</PASSWORD>
' This sequence should be repeated For Each network drive
' The network mapping is done each time we find the "<PASSWORD>" line
' Initilizing connection information
Password=""
Username=""
Path=""
' Opening the file in priority order
If fso.FileExists(BOOTDIR & "networkdisk.txt") Then
Set f = fso.OpenTextFile(BOOTDIR & "networkdisk.txt",1)
Else
Set f = fso.OpenTextFile(TOOLSDIR & "networkdisk.txt",1)
End If
On Error Resume Next
Do While f.AtEndOfStream <> True
ReadTextFile=f.ReadLine
' Check and extract Parameters from the configuration file (XML like format)
If XMLDataExtractor (value,ReadTextFile,"USERNAME") Then
Username=value
End If
If XMLDataExtractor (value,ReadTextFile,"PASSWORD") Then
Password=value
' Excute the mapping of the network drive, errors are ignored
Set Wshnet=WScript.CreateObject("WScript.Network")
On Error Resume Next
' Network drive mapping"
Wshnet.MapNetworkDrive Chr(NTWDRVLETTER)& ":",Path,True,Username,Password
If fso.FolderExists(Path) Then
' Mapping is Ok: change the letter for the next drive mapping
NTWDRVLETTER=NTWDRVLETTER+1
End If
' Reseting connections parameters (in case of several mappings need to be done)
Password=""
Username=""
Path=""
Set Wshnet = Nothing
End If
If XMLDataExtractor (value,ReadTextFile,"PATH") Then
Path=value
End If
Loop
On Error Goto 0
f.Close
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Load Drivers Network drives using info from networkdisk.txt
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub LoadDrivers()
Dim WshShell,fso
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists("X:\" & DRVDIR) Then WshShell.Run "drvload.exe " & "X:\" & DRVDIR,1,True
If fso.FolderExists(TOOLSDIR & DRVDIR) Then WshShell.Run "drvload.exe " & TOOLSDIR & DRVDIR,1,True
If fso.FolderExists(BOOTDIR & DRVDIR) Then WshShell.Run "drvload.exe " & BOOTDIR & DRVDIR,1,True
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Getting Network adpater status
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This Function checks if the network card is :
' present
' connected a physical network network
' have a TCP/IP address
Sub DisplayNetworkAdapterInfo (ByRef mess)
Dim objWMIService, objItem, colItems
Dim objWMIService2, objItem2, colItems2
Dim intAdapter
Dim x
intAdapter = 0
' WMI connection to Root CIM
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter")
For Each objItem In colItems
' Take only Ethenert physical cards
If objItem.AdapterType="Ethernet 802.3" And objItem.PhysicalAdapter Then
intAdapter=intAdapter +1
' If the card is connected to the network, check the TCP/IP status
If objItem.NetConnectionStatus=2 Then
Set colItems2 = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
For Each objItem2 In colItems2
' Retreiving the card comparing the MAC address
If objItem.MACAddress=objItem2.MACAddress Then
' Extracting TCP/IP address
If Not IsNull(objItem2.IPAddress) Then
'Ethernet Adapter section title for the first adapter listed
If intAdapter=1 Then mess = mess & vbCrLf & StrNetworkAdaptTitle & vbCrLf
' Display of adapter TCP/IP address and the DHCP server address
mess = mess & StrNetAddress & objItem2.IPAddress(0) & vbTab & vbTab & StrDHCPServer & objItem2.DHCPServer & vbCrLf
End If
End If
Next
Else
'Ethernet Adapter section title for the first adapter listed
If intAdapter=1 Then mess = mess & vbCrLf & StrNetworkAdaptTitle & vbCrLf
mess = mess & StrNotConnected & vbCrLf
End If
End If
Next
' Alert message if network adpater is not found
If intAdapter = 0 Then mess = mess & vbCrLf & StrNetAdaptNotFound & vbCrLf
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Getting Physical drives information
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This Function scans the fixed disks available In the machine
'and detect if the system don't have any fixed hard drive
Sub DisplayFixedHrdDriveInfo (ByRef mess)
Dim objWMIService, objItem, colItems, strComputer, intDrive
intDrive = 0
PHYSDRIVNB=0
' WMI connection to Root CIM
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
'Disk section title
mess = mess & StrFixedDisks & vbCrLf
For Each objItem In colItems
intDrive = intDrive + 1
If objItem.MediaType="Fixed hard disk media" Then
PHYSDRIVNB=PHYSDRIVNB +1
mess = mess & StrDisknb & PHYSDRIVNB & vbTab &vbTab & vbTab
mess = mess & StrCaption & objItem.Caption & vbCrLf
mess = mess & StrPartition & objItem.Partitions & vbTab & vbTab
mess = mess & StrModel & objItem.Model & vbCrLf
' Convert the drive size to Gigabytes
DRVSIZE(intDrive)=Int (objItem.Size/1024/1024/1024)
DRVSIZEMO(intDrive)=Int (objItem.Size/1024/1024)
mess = mess & StrSize & CLng (objItem.Size/1024/1024/1024) & " GB" & vbCrLf
End If
Next
'No Fixed Hard drive availabe : Windows installation is not possible"
If PHYSDRIVNB=0 Then
mess = mess & StrHardDrvNotFound & vbCrLf
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Getting Memory information
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DisplayMemoryInfo (ByRef mess)
Dim TotalMem, objWMIService, BankNumber
TotalMem=0
BankNumber=1
mess= mess & StrMemTitle & vbCrLf
For Each objWMIService In GetObject("winmgmts:{impersonationLevel=impersonate}\\.\root\cimv2").InstancesOf("Win32_PhysicalMemory")
BankNumber = BankNumber +1
If Len (objWMIService.BankLabel) = 0 Then
mess = mess & StrMemBank & BankNumber & " "
Else
mess = mess & StrMemBank & objWMIService.BankLabel & " "
End If
mess = mess & StrMemSize & objWMIService.Capacity/1024/1024 & " MB" & " "
mess = mess & StrMemSpeed & objWMIService.Speed & " Mhz"
mess = mess & vbCrLf
TotalMem=TotalMem+objWMIService.Capacity/1024/1024
Next
mess = mess & StrMemTotalSize & TotalMem & " MB" & vbCrLf
mess = mess & vbCrLf
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Getting BIOS information
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BiosProperties(ByRef mess)
Dim strComputer
Dim objWMIService
Dim ColBIOS,objBIOS
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set ColBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")
'BIOS section title and the BIOS date
mess = mess & StrBIOS & vbTab & "(" & Now() & ")" & vbCrLf
For Each objBIOS In ColBIOS
mess = mess & StrManufacturer & objBIOS.Manufacturer & vbCrLf
mess = mess & StrRelDate & Left(objBIOS.ReleaseDate,8) & vbCrLf
mess = mess & StrVersion & objBIOS.Version & vbCrLf
mess = mess & vbCrLf
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Getting Processor information
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub DisplayProcessorInfo (ByRef mess)
Dim objWMIService, colItems
Dim objItem
'Processor section title
mess = mess & StrProcessor & vbCrLf
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem In colItems
mess = mess & StrName & objItem.Name & vbCrLf
mess = mess & StrDescription & objItem.Description & vbCrLf
mess = mess & StrMaxClockSpeed & objItem.MaxClockSpeed & vbTab & vbTab
mess = mess & StrCurClockSpeed & objItem.CurrentClockSpeed & vbCrLf
mess = mess & StrL2CacheSize & objItem.L2CacheSize & vbTab & vbTab & vbTab
mess = mess & StrManufacturer & objItem.Manufacturer & vbCrLf
mess = mess & StrRevision & objItem.Revision & vbTab & vbTab & vbTab
mess = mess & StrSocket & objItem.SocketDesignation & vbCrLf
mess = mess & vbCrLf
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Tranfer from of the tool from DVD to an UFD
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'The function do a first drive scan without any removable connected
' and do a second scan with the UFD drive connected
Sub TransferToUfd()
Dim NbOfDisk1,NbOfDisk2,UfdPartition
Dim FormatCmd,CopyCmd
Dim UfdFound
Dim objWMIService, objItem, colItems, strComputer
Dim fso,i,d
Dim objFileSystem, objOutputFile
Dim strOutputFile
Dim WshShell, oExec
' The function is not supported if the system is boot from an UFD
If BOOTFROM=2 Then
MsgBox StrWarningBootUFD,vbExclamation,StrWarningTitle
Exit Sub
End If
' The user should first dicconnect All removable Media
MsgBox StrRemoveRemovMedia
' WMI connection to Root CIM
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
'First scan of the system drives
NbOfDisk1=0
For Each objItem In colItems
NbOfDisk1 = NbOfDisk1 + 1
Next
' Warning message before formatting UFD
MsgBox StrWarningUfdPartition,vbExclamation,StrWarningTitle
' The user should connect the UFD
MsgBox StrConnectUFD & DVDSIZE & " MB)"
'Second scan of the system drives with a check of the minimum size of the UFD
NbOfDisk2=0
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_DiskDrive")
UfdFound=0
NbOfDisk2=0
For Each objItem In colItems
NbOfDisk2 = NbOfDisk2 + 1
'Search removable drive
If objItem.MediaType="Removable Media" Then
If Int (objItem.Size/1024/1024) > DVDSIZE Then
UfdFound=1
Else
MsgBox StrUFDNotEnoughSpace
Exit Sub
End If
End If
Next
'Display warning message if UFD is not found
If NbOfDisk1+1<>NbOfDisk2 Then
MsgBox StrUFDNotFound
Else
' Build the Diskpart command file
strOutputFile = TOOLSDIR & "diskconf.cmd"
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objOutputFile = objFileSystem.CreateTextFile(strOutputFile, True)
objOutputFile.WriteLine("Select Disk "& NbOfDisk1)
objOutputFile.WriteLine("Clean")
objOutputFile.WriteLine("Create Partition Primary")
objOutputFile.WriteLine("Select Partition 1")
objOutputFile.WriteLine("Active")
objOutputFile.WriteLine("Format FS=FAT32 Label=" & Chr(34) & UFDLABEL & Chr(34) & " QUICK")
objOutputFile.WriteLine("Assign")
objOutputFile.WriteLine("Exit")
objOutputFile.Close
' Launch the Diskpart command
Set WshShell = WScript.CreateObject("WScript.Shell")
FormatCmd="DISKPART /S " & TOOLSDIR & "Diskconf.cmd"
WshShell.Run FormatCmd,1,True
'Getting Partitions infortmation
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
For i=Asc("C") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
If d.VolumeName=UFDLABEL Then
UfdPartition=d.DriveLetter
End If
End If
End If
Next
' Launch the Copy of the DVD to the UDF
CopyCmd="xcopy " & BOOTDIR & "*.* /s /e /f " & UfdPartition & ":\"
WshShell.Run CopyCmd,1,True
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This function Make a simple backup of the C:\ partition
' to the root of a avalabe logical disk (could be a network drive)
' disk using Imagex. If the backup file already exist then
' the backup is done using "append" mode.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub BackupCPart()
Dim fso,WshShell,mess, nbpart
Dim CPartitionSize
Dim i,d,NbOfPartitionAvailable,ImageXCmd,j
Dim DriveSize(10),DriveLetter(10),DriveLabel(10), DriveToCapture(10)
Dim Label,WimFileName, sysPart,diskToCapture
mess = ""
' WMI connection to Root CIM
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
'Checking the number of partition scanning diks letter to C to W
For i=Asc("C") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
If d.DriveType=2 Then
nbpart=nbpart+1
End If
End If
End If
Next
j=1
sysPart = False
'Display The numbers of partition
If nbpart =0 Then
mess = mess & vbCrLf & StrNoFormattedPartition & vbCrLf
Else
mess = mess & vbCrLf & StrFormattedPartition & vbCrLf
End If
'Scan Hard Drives info from Letter C to Letter W (to avoid to see the WinPE default drive (X:))
' and dsiplay info about partition
For i=Asc("C") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
If d.IsReady Then
If d.DriveType=2 Then
DriveToCapture(j)=Chr(i)
mess = mess & j & " - " & StrLetter & d.DriveLetter& vbTab & StrLabel & d.VolumeName & vbTab
mess = mess & CLng(d.Totalsize/1024/1024/1024) & "/" & CLng((d.Totalsize-d.AvailableSpace)/1024/1024/1024) & " GB" & vbCrLf
If CLng(d.Totalsize/1024/1024) <= 512 then
sysPart = True
End If
j = j+1
End If
End If
End If
Next
' MsbBox to alert that there is a system partition
if sysPart then
MsgBox StrMultiPartition
end if
' asking which partition must be captured
choice=NumChoiceInputBox(mess,StrTitleWichPartition,"1",j-1)
diskToCapture = choice
set d = fso.GetDrive(DriveToCapture(choice))
If d.IsReady Then
If d.DriveType=2 Then
' Get the size of the partition to backup
CPartitionSize=Round ((d.Totalsize-d.AvailableSpace)/1024/1024/1024,2)
End If
End If
' Asking to the user to connect a drive and specifying the size of the partition
MsgBox StrBckConnectDrive &" "& CPartitionSize & " GB"
NbOfPartitionAvailable=0
'The size of the available partition is not checked due to the imageX compression rate
'that is difficult to predict depending of the data on the C:\ partition.
'From D to W
For i=Asc("D") To Asc("W")
If fso.DriveExists(Chr(i)) Then
Set d = fso.GetDrive(Chr(i))
' Limit to Network drive If d.IsReady and d.DriveType=3 Then
If d.IsReady Then
' Removable Media, Fixed drives and network drives are Ok
' If d.DriveType=1 Or d.DriveType=2 Or d.DriveType=3 Or d.DriveType=4 Then
If d.AvailableSpace >0 Then
NbOfPartitionAvailable=NbOfPartitionAvailable + 1
DriveLetter(NbOfPartitionAvailable)= Chr(i) & ":\"
'Replacing Network drive letter by the network path
If d.DriveType=3 Then
DriveLetter(NbOfPartitionAvailable)=GetNetworkDrivePath(DriveLetter(NbOfPartitionAvailable))
End If
DriveSize(NbOfPartitionAvailable)=Round (d.AvailableSpace/1024/1024/1024,2)
DriveLabel(NbOfPartitionAvailable)=d.VolumeName
End If
'End If
End If
End If
Next
mess = ""
'Back to the main menu if no partition are found
If NbOfPartitionAvailable=0 Then
MsgBox StrBckDestDrvNotFound
Exit Sub
End If
For i = 1 To NbOfPartitionAvailable
mess = mess & i & vbTab & DriveLetter(i)& vbTab & DriveLabel(i)& vbTab & "(" &DriveSize(i) & " GB)" & vbCrLf
Next
mess = mess & vbCrLf & StrBckChooseDestPart
' Display the choice menu with all images available
choice=NumChoiceInputBox(mess,StrBckAvailablePartitions,"1",NbOfPartitionAvailable)
If choice=0 Then Exit Sub
' Get the Wim File name
WimFileName=InputBox(StrBckEnterWimFileName,"","SevenImage.wim")
' Delete of blank characters
WimFileName=Trim(WimFileName)
If Len (WimFileName)=0 Then
Exit Sub
End If
'Conversion to lowercase
WimFileName=LCase(WimFileName)
' Check if the wim extension has been entererd by the user,
' if not the .wim extension is added to the filename
If Len(WimFileName)>=4 Then
If Right(WimFileName,4)<>".wim" Then WimFileName=WimFileName & ".wim"
End If
' Get the Label name of the backup
Label=InputBox(StrBckEnterLabelName)
' Delete of blank characters
Label=Trim(Label)
If Len (Label)=0 Then
Exit Sub
End If
' 25 Charaters maximum for the image label name, other charcaters are truncated
If Len (Label)>25 Then
Label=Left(Label,25)
End If
' If the \images directory exists the wimfile is created in it instead
' of the drive root directory
If fso.FolderExists(DriveLetter(choice) & IMAGEDIR) Then WimFileName=IMAGEDIR &"\"& WimFileName
' Creation of the ImageX Command
If fso.FileExists(DriveLetter(choice) & WimFileName) Then
ImageXCmd=TOOLSDIR & "imagex /append " & DriveToCapture(diskToCapture) & ":\ " & DriveLetter(choice) & WimFileName & " " & Chr(34) & Label & Chr(34)
Else
ImageXCmd=TOOLSDIR & "imagex /capture " & DriveToCapture(diskToCapture) & ":\ " & DriveLetter(choice) & WimFileName & " " & Chr(34) & Label & Chr(34)
End If
'Start the Imagex Command
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ImageXCmd,1,True
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''
' This function extracts Data from an XML style line
''''''''''''''''''''''''''''''''''''''''''''''''''
Function XMLDataExtractor(ByRef value,line, tag )
Dim ltag
value=line
'Removing blanck characters from the input line
value=Trim(value)
ltag=Len(tag)+2
' basic checks
XMLDataExtractor=0
If value="" Then Exit Function
If ltag=2 Then Exit Function
If Len(value) <= (ltag * 2) + 1 Then Exit Function
' eliminating control character at the end of the line
If Right(value,1) < Chr(20) Then
value = Left (value,(Len (value) -1))
End If
' Checking the tag is present"
If Left(value,ltag) = "<" & tag & ">" And Right(value,(ltag+1)) = "</" & tag & ">" Then '
XMLDataExtractor=1
' Get the value
value =Right(value,Len(value) - ltag)
value =Left(value,Len (value) - ltag-1)
End If
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This function converts a very long integer (Image size in Bytes)
' into a 2 decimal number representing the size in Giga Bytes
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ConvertGBSize (ByRef GbSize)
Dim Size1,Size2
Size1=0
Size2=0
'Converting the Left part of the String
Size1=CLng(Right(GBSize,9)) /1024/1024/1024
'Converting the right part of the string
If Len(GbSize) > 9 Then
Size2= CLng(Left(GBSize,(Len(GbSize)-9)))/1.024/1.024/1.024
End If
'Returning the total value with 2 decimal
ConvertGBSize=Round(Size1 + Size2,2)
End Function
Function NumChoiceInputBox(mess,Title,mode,nbchoice)
Dim choice
Dim s
Do
' Display the Menu
s=InputBox (mess,Title,mode)
If s="" Then
NumChoiceInputBox=0
Exit Function
End If
On Error Resume Next
choice=CInt(s)
If Err.Number<>0 Then
Err.Clear
choice=-1
End If
If choice>=1 And choice<=nbchoice Then
NumChoiceInputBox=choice
Exit Function
End If
Loop
End Function
Function PopUpMenu(mess,title,mode,timeout)
Dim Answer
Dim oShell
Set oShell = WScript.CreateObject("WScript.Shell")
PopUpMenu = oShell.Popup (mess,timeout,title,mode)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Get tranlated messages from menu-messages.txt file
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub GetTranslatedStrings()
Dim fso,f,ReadTextFile
Dim value
Dim Path,Username,Password
Dim Wshnet
Dim UnicodeFile
Dim ReadChar,LowByte,HiByte
Set fso = CreateObject("Scripting.FileSystemObject")
' Check if the message file : menu-messages.txt does exist in the tools directory
If Not fso.FileExists(TOOLSDIR & "menu-messages.txt") Then
Exit Sub
End If
' Check if the file is Unicode or not checking the 2 first bytes in the file.
UnicodeFile=False
Set f = fso.OpenTextFile(TOOLSDIR & "menu-messages.txt",1)
LowByte=f.Read(1)
HiByte=f.Read(1)
If Asc(LowByte)=255 And Asc(HiByte)=254 Then UnicodeFile=True
f.Close
' Read each line containing a translated message has
' VB Script like syntax : MyString="Format Hard Drive"
' File message is could be either simple txt file of Unicode Txt file
' for languages like Chinese, Russian, Czech.
Set f = fso.OpenTextFile(TOOLSDIR & "menu-messages.txt",1)
On Error Resume Next
' Reading the 2 first charactres of the unicode file
' to set the pointer to the beginning of text messagaes'
If UnicodeFile = True Then f.read(2)
Do While f.AtEndOfStream <> True
' Read of an Unicode file line
If UnicodeFile = True Then
ReadTextFile=""
Do While f.AtEndOfStream <> True
LowByte=f.Read(1)
HiByte=f.Read(1)
If LowByte=vbCr And HiByte= Chr(0) Then
' Read the Line Feed Character (2 bytes in Unicode) and exit the loop
f.Read(1)
f.Read(1)
Exit Do
End If
ReadChar=(Asc(HiByte)*256) + Asc(LowByte)
ReadTextFile=ReadTextFile & chrW(ReadChar)
Loop
Else
' Read of a regular text file line
ReadTextFile=f.ReadLine
End If
' Main Menu Strings
If CheckParameter("StrMainMenuTitle",ReadTextFile) Then StrMainMenuTitle=GetString(ReadTextFile)
If CheckParameter("StrFormatHardDrive",ReadTextFile) Then StrFormatHardDrive=GetString(ReadTextFile)
If CheckParameter("StrSystemProperties",ReadTextFile) Then StrSystemProperties=GetString(ReadTextFile)
If CheckParameter("StrDeployImages",ReadTextFile) Then StrDeployImages=GetString(ReadTextFile)
If CheckParameter("StrDeployImagesAndReboot",ReadTextFile) Then StrDeployImagesAndReboot=GetString(ReadTextFile)
If CheckParameter("StrImagexBackUp",ReadTextFile) Then StrImagexBackUp=GetString(ReadTextFile)
If CheckParameter("StrStartWinPEConsole",ReadTextFile) Then StrStartWinPEConsole=GetString(ReadTextFile)
If CheckParameter("StrRestartSystem",ReadTextFile) Then StrRestartSystem=GetString(ReadTextFile)
If CheckParameter("StrTranferToUfd",ReadTextFile) Then StrTranferToUfd=GetString(ReadTextFile)
If CheckParameter("StrChooseOption",ReadTextFile) Then StrChooseOption=GetString(ReadTextFile)
If CheckParameter("StrRestoreBoot",ReadTextFile) Then StrRestoreBoot=GetString(ReadTextFile)
' Main Menu Cancel menu strings
If CheckParameter("StrCancel",ReadTextFile) Then StrCancel=GetString(ReadTextFile)
If CheckParameter("StrCancelWinPE",ReadTextFile) Then StrCancelWinPE=GetString(ReadTextFile)
If CheckParameter("StrCancelTitle",ReadTextFile) Then StrCancelTitle=GetString(ReadTextFile)
'Welcome box strings with Trademark symbol and Registration mark
If CheckParameter("StrWelcomeTitle",ReadTextFile) Then StrWelcomeTitle=GetString(ReadTextFile)
If CheckParameter("StrWelcome1",ReadTextFile) Then StrWelcome1=GetString(ReadTextFile)
If CheckParameter("StrWelcome2",ReadTextFile) Then StrWelcome2=GetString(ReadTextFile)
If CheckParameter("StrWelcome3",ReadTextFile) Then StrWelcome3=GetString(ReadTextFile)
If CheckParameter("StrWelcome4",ReadTextFile) Then StrWelcome4=GetString(ReadTextFile)
If CheckParameter("StrWelcome5",ReadTextFile) Then StrWelcome5=GetString(ReadTextFile)
'WinPE Console box strings
If CheckParameter("StrExitWinPEConsole",ReadTextFile) Then StrExitWinPEConsole=GetString(ReadTextFile)
'System Properties box strings
If CheckParameter("StrSystemPropTitle",ReadTextFile) Then StrSystemPropTitle=GetString(ReadTextFile)
If CheckParameter("StrBIOS",ReadTextFile) Then StrBIOS=GetString(ReadTextFile)
If CheckParameter("StrCDROM",ReadTextFile) Then StrCDROM=GetString(ReadTextFile)
If CheckParameter("StrProcessor",ReadTextFile) Then StrProcessor=GetString(ReadTextFile)
If CheckParameter("StrName",ReadTextFile) Then StrName=GetString(ReadTextFile)
If CheckParameter("StrDescription",ReadTextFile) Then StrDescription=GetString(ReadTextFile)
If CheckParameter("StrMaxClockSpeed",ReadTextFile) Then StrMaxClockSpeed=GetString(ReadTextFile)
If CheckParameter("StrCurClockSpeed",ReadTextFile) Then StrCurClockSpeed=GetString(ReadTextFile)
If CheckParameter("StrL2CacheSize",ReadTextFile) Then StrL2CacheSize=GetString(ReadTextFile)
If CheckParameter("StrRevision",ReadTextFile) Then StrRevision=GetString(ReadTextFile)
If CheckParameter("StrManufacturer",ReadTextFile) Then StrManufacturer=GetString(ReadTextFile)
If CheckParameter("StrSocket",ReadTextFile) Then StrSocket=GetString(ReadTextFile)
If CheckParameter("StrRelDate",ReadTextFile) Then StrRelDate=GetString(ReadTextFile)
If CheckParameter("StrSMBIOSVer",ReadTextFile) Then StrSMBIOSVer=GetString(ReadTextFile)
If CheckParameter("StrSMBIOSMajVer",ReadTextFile) Then StrSMBIOSMajVer=GetString(ReadTextFile)
If CheckParameter("StrSMBIOSMinVer",ReadTextFile) Then StrSMBIOSMinVer=GetString(ReadTextFile)
If CheckParameter("StrVersion",ReadTextFile) Then StrVersion=GetString(ReadTextFile)
If CheckParameter("StrDisknb",ReadTextFile) Then StrDisknb=GetString(ReadTextFile)
If CheckParameter("StrDisk",ReadTextFile) Then StrDisk=GetString(ReadTextFile)
If CheckParameter("StrNbPartitions",ReadTextFile) Then StrNbPartitions=GetString(ReadTextFile)
If CheckParameter("StrPartition",ReadTextFile) Then StrPartition=GetString(ReadTextFile)
If CheckParameter("StrSize",ReadTextFile) Then StrSize=GetString(ReadTextFile)
If CheckParameter("StrGigaOctets",ReadTextFile) Then StrGigaOctets=GetString(ReadTextFile)
If CheckParameter("StrCaption",ReadTextFile) Then StrCaption=GetString(ReadTextFile)
If CheckParameter("StrModel",ReadTextFile) Then StrModel=GetString(ReadTextFile)
If CheckParameter("StrPartitionLabel",ReadTextFile) Then StrPartitionLabel=GetString(ReadTextFile)
If CheckParameter("StrTotSpace",ReadTextFile) Then StrTotSpace=GetString(ReadTextFile)
If CheckParameter("StrFileSystem",ReadTextFile) Then StrFileSystem=GetString(ReadTextFile)
If CheckParameter("StrFormattedPartition",ReadTextFile) Then StrFormattedPartition=GetString(ReadTextFile)
If CheckParameter("StrFixedDisks",ReadTextFile) Then StrFixedDisks=GetString(ReadTextFile)
If CheckParameter("StrNoNetDisk",ReadTextFile) Then StrNoNetDisk=GetString(ReadTextFile)
If CheckParameter("StrNetDisk",ReadTextFile) Then StrNetDisk=GetString(ReadTextFile)
If CheckParameter("StrLetter",ReadTextFile) Then StrLetter=GetString(ReadTextFile)
If CheckParameter("StrLabel",ReadTextFile) Then StrLabel=GetString(ReadTextFile)
If CheckParameter("StrNoFormattedPartition",ReadTextFile) Then StrNoFormattedPartition=GetString(ReadTextFile)
If CheckParameter("StrHardDrvNotFound",ReadTextFile) Then StrHardDrvNotFound=GetString(ReadTextFile)
' Memory
If CheckParameter("StrMemTitle",ReadTextFile) Then StrMemTitle=GetString(ReadTextFile)
If CheckParameter("StrMemBank",ReadTextFile) Then StrMemBank=GetString(ReadTextFile)
If CheckParameter("StrMemSize",ReadTextFile) Then StrMemSize=GetString(ReadTextFile)
If CheckParameter("StrMemTotalSize",ReadTextFile) Then StrMemTotalSize=GetString(ReadTextFile)
If CheckParameter("StrMemSpeed",ReadTextFile) Then StrMemSpeed=GetString(ReadTextFile)
' Network adpater section
If CheckParameter("StrNetworkAdaptTitle",ReadTextFile) Then StrNetworkAdaptTitle=GetString(ReadTextFile)
If CheckParameter("StrConnected",ReadTextFile) Then StrConnected=GetString(ReadTextFile)
If CheckParameter("StrNetAddress",ReadTextFile) Then StrNetAddress=GetString(ReadTextFile)
If CheckParameter("StrDHCPServer",ReadTextFile) Then StrDHCPServer=GetString(ReadTextFile)
If CheckParameter("StrNotConnected",ReadTextFile) Then StrNotConnected=GetString(ReadTextFile)
If CheckParameter("StrNetAdaptNotFound",ReadTextFile) Then StrNetAdaptNotFound=GetString(ReadTextFile)
'Partitions Menu box strings
If CheckParameter("StrPartitionsNameTitle",ReadTextFile) Then StrPartitionsNameTitle=GetString(ReadTextFile)
If CheckParameter("StrPartitionsSizeTitle",ReadTextFile) Then StrPartitionsSizeTitle=GetString(ReadTextFile)
If CheckParameter("StrHowManyPartitionsTitle",ReadTextFile) Then StrHowManyPartitionsTitle=GetString(ReadTextFile)
If CheckParameter("StrHowManyPartition",ReadTextFile) Then StrHowManyPartition=GetString(ReadTextFile)
If CheckParameter("StrOneOrTwo",ReadTextFile) Then StrOneOrTwo=GetString(ReadTextFile)
If CheckParameter("StrQuestionPartitionSize",ReadTextFile) Then StrQuestionPartitionSize=GetString(ReadTextFile)
If CheckParameter("StrQuestGigaOctets",ReadTextFile) Then StrQuestGigaOctets=GetString(ReadTextFile)
If CheckParameter("StrQuestPartitionName",ReadTextFile) Then StrQuestPartitionName=GetString(ReadTextFile)
If CheckParameter("StrQuestMaxChar",ReadTextFile) Then StrQuestMaxChar=GetString(ReadTextFile)
If CheckParameter("StrBootFromTestEnv",ReadTextFile) Then StrBootFromTestEnv=GetString(ReadTextFile)
If CheckParameter("StrBootFromCDROM",ReadTextFile) Then StrBootFromCDROM=GetString(ReadTextFile)
If CheckParameter("StrBootFromUFD",ReadTextFile) Then StrBootFromUFD=GetString(ReadTextFile)
If CheckParameter("StrWarningPartition",ReadTextFile) Then StrWarningPartition=GetString(ReadTextFile)
If CheckParameter("StrWarningTitle",ReadTextFile) Then StrWarningTitle=GetString(ReadTextFile)
'UFD transfer Menu boxes strings
If CheckParameter("StrRemoveRemovMedia",ReadTextFile) Then StrRemoveRemovMedia=GetString(ReadTextFile)
If CheckParameter("StrConnectUFD",ReadTextFile) Then StrConnectUFD=GetString(ReadTextFile)
If CheckParameter("StrUFDNotEnoughSpace",ReadTextFile) Then StrUFDNotEnoughSpace=GetString(ReadTextFile)
If CheckParameter("StrUFDNotFound",ReadTextFile) Then StrUFDNotFound=GetString(ReadTextFile)
If CheckParameter("StrWarningUfdPartition",ReadTextFile) Then StrWarningUfdPartition=GetString(ReadTextFile)
If CheckParameter("StrWarningBootUFD",ReadTextFile) Then StrWarningBootUFD=GetString(ReadTextFile)
'Image deployment box strings
If CheckParameter("StrDeplWarning",ReadTextFile) Then StrDeplWarning=GetString(ReadTextFile)
If CheckParameter("StrDeplChoice",ReadTextFile) Then StrDeplChoice=GetString(ReadTextFile)
If CheckParameter("StrDeplAvailImages",ReadTextFile) Then StrDeplAvailImages=GetString(ReadTextFile)
If CheckParameter("StrDeplCPartitionToSmall",ReadTextFile) Then StrDeplCPartitionToSmall=GetString(ReadTextFile)
If CheckParameter("StrDeplCPartitionNotFound",ReadTextFile) Then StrDeplCPartitionNotFound=GetString(ReadTextFile)
If CheckParameter("StrDeplWimFileNotFound",ReadTextFile) Then StrDeplWimFileNotFound=GetString(ReadTextFile)
If CheckParameter("StrDeplFormatFault",ReadTextFile) Then StrDeplFormatFault=GetString(ReadTextFile)
If CheckParameter("strMultiPartition",ReadTextFile) Then strMultiPartition=GetString(ReadTextFile)
'Backup box strings
If CheckParameter("StrBckDriveNotFound",ReadTextFile) Then StrBckDriveNotFound=GetString(ReadTextFile)
If CheckParameter("StrBckConnectDrive",ReadTextFile) Then StrBckConnectDrive=GetString(ReadTextFile)
If CheckParameter("StrBckDestDrvNotFound",ReadTextFile) Then StrBckDestDrvNotFound=GetString(ReadTextFile)
If CheckParameter("StrBckChooseDestPart",ReadTextFile) Then StrBckChooseDestPart=GetString(ReadTextFile)
If CheckParameter("StrBckAvailablePartitions",ReadTextFile) Then StrBckAvailablePartitions=GetString(ReadTextFile)
If CheckParameter("StrBckEnterWimFileName",ReadTextFile) Then StrBckEnterWimFileName=GetString(ReadTextFile)
If CheckParameter("StrBckEnterLabelName",ReadTextFile) Then StrBckEnterLabelName=GetString(ReadTextFile)
'Boot Loader box strings
If CheckParameter("StrBootLoaderWinDir",ReadTextFile) Then StrBootLoaderWinDir=GetString(ReadTextFile)
If CheckParameter("StrBootLoaderWinDirTitle",ReadTextFile) Then StrBootLoaderWinDirTitle=GetString(ReadTextFile)
If CheckParameter("StrFolderDoesntExist",ReadTextFile) Then StrFolderDoesntExist=GetString(ReadTextFile)
If CheckParameter("StrBootLoaderBootDir",ReadTextFile) Then StrBootLoaderBootDir=GetString(ReadTextFile)
If CheckParameter("StrBootLoaderBootDirTitle",ReadTextFile) Then StrBootLoaderBootDirTitle=GetString(ReadTextFile)
If CheckParameter("StrDriveDoesntExist",ReadTextFile) Then StrDriveDoesntExist=GetString(ReadTextFile)
Loop
On Error Goto 0
f.Close
End Sub
' This function checks if the Parameter matchs with the TextLine
Function CheckParameter(Parameter,TextLine)
CheckParameter=False
If Parameter & "=" = Left(TextLine,Len(Parameter)+1) Then
CheckParameter=True
End If
End Function
' This function extracts the message from the text Line
Function GetString(TextLine)
Dim ptr1,ptr2
' Finding to position of the message (between " characters)
ptr1=InStr(TextLine,Chr(34))
ptr2=InStrRev(TextLine,Chr(34))
' Checking that the line is valid
If ptr1<>0 And ptr2 > ptr1 Then
GetString=Mid(TextLine,ptr1+1,ptr2-ptr1-1)
Exit Function
End If
' The line is not valid"
GetString=""
End Function |
Partager