Jump to content


  • Posts

  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Everything posted by WreX

  1. This will give you IPv4 addresses: For Each objItem in colItems If Not IsNull(objItem.IPAddress) Then ' This adapter has an IP address For Each valIPAddr in objItem.IPAddress If InStr(valIPAddr,".") <> 0 Then ' If this is an IPv4 (#.#.#.#) address, not IPv6 (xx:xx:xx:xx...) strIPAddress = valIPAddr strDHCPIP = objItem.DHCPServer End If Next End If Next
  2. The data retrieved from WMI is static, you can't tell it to give it to you in a different value, so here's some pseudo code to do the conversion: If valMemSize > 1073741824 Then ' If more than 1GB arrMemSize = Split( (valMemSize / 1073741824),".") ' Ex. 1.5GB, arrMemSize(0) = 1, arrMemSize(1) = 5 strMemSize = arrMemSize(0) & "." & Left(arrMemSize(1),1) & "GB" ' Left(val,1) for 1 number right of decimal point End If
  3. Try using Win32_ComputerSystem.TotalPhysicalMemory. Scriptomatic v2 by the Microsoft Scripting Guys is a good tool for seeing all the available WMI classes and their values. Scriptomatic V2
  4. I'm developing an automated XP deployment using WinPE 2.0 and WIM image files. I'm using the Vista boot loader configured with bcdedit to launch a custom PE WIM on C: into RAM, and a legacy ntldr pointing at D:. The problem I'm encountering is that I can get everything configured as desired, apply the XP WIM to D:, ready to boot into Sysprep, but after Sysprep completes, my BCD entry for booting PE has been cleared of everything but the identifier and subsequently is no longer bootable! While in the initial PE boot from CD the hard disk is partitioned and formatted NTFS with diskpart, then the boot loader configured with bcdedit, including "bootsect /nt60 c:". Then NTLDR, NTDETECT.COM, and boot.ini are copied to C:\ and the OS image applied to D:\ with D:\Sysprep\sysprep.inf getting customized. The reboot after that is able to load the PE WIM on C:, but if the Sysprep mini-install runs, the details for the PE WIM magically disappear. Here's the command used to get Sysprep ready: Sysprep -pnp -reboot -mini -activated -reseal Here's what's in Sysprep.inf: [Unattended] OemSkipEula=Yes UnattendMode=FullUnattended DriverSigningPolicy=Ignore OemPnpDriversPath=*Lots of folders* InstallFilesPath=\Sysprep\i386 ; OemPreinstall=Yes ; ExtendOEMPartition=1 [WindowsFirewall] Profiles = WindowsFirewall.TurnOffFirewall [WindowsFirewall.TurnOffFirewall] Mode = 0 [GuiUnattended] OEMDuplicatorstring=*Description* AdminPassword=*The password* OEMSkipRegional=1 TimeZone=35 OemSkipWelcome=1 AutoLogon=Yes AutoLogonCount=1 [UserData] ProductID=*ID* FullName=*Name* OrgName="*Name*" ComputerName=*Custom Computer name* [Identification] JoinWorkgroup=*Workgroup Name* [Networking] InstallDefaultComponents=Yes Here are the commands used to configure the BCD: xcopy %CDROM%:\BOOT\*.* /e /f /y C:\BOOT\ copy %CDROM%:\BOOTMGR C:\ IF EXIST C:\BOOT\BCD DEL C:\BOOT\BCD IF NOT EXIST C:\TEMP MD C:\TEMP IF EXIST C:\TEMP\BCD DEL C:\TEMP\BCD bcdedit -createstore C:\TEMP\BCD bcdedit -store C:\TEMP\BCD -create {bootmgr} /d "Boot Manager" bcdedit -store C:\TEMP\BCD -set {bootmgr} device boot bcdedit -store C:\TEMP\BCD -create {ramdiskoptions} /d "WinPE" bcdedit -import C:\TEMP\BCD bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C: bcdedit -set {ramdiskoptions} ramdisksdipath \BOOT\BOOT.sdi for /f "tokens=3" %%a in ('bcdedit -create /d "WinPE" -application osloader') do set guid=%%a bcdedit -set %guid% device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions} bcdedit -set %guid% path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE bcdedit -set %guid% osdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions} bcdedit -set %guid% systemroot \WINDOWS bcdedit -set %guid% winpe yes bcdedit -set %guid% detecthal yes bcdedit -displayorder %guid% -addlast bcdedit -create {ntldr} /d "Microsoft Windows XP Professional" bcdedit -set {ntldr} device boot bcdedit -set {ntldr} path \ntldr bcdedit -displayorder {ntldr} -addfirst bcdedit -default {ntldr} bcdedit -timeout 5 bootsect /nt60 C: IF EXIST C:\TEMP\BCD DEL C:\TEMP\BCD bcdedit Here's what bcdedit shows before Sysprep: Windows Boot Manager -------------------- identifier {bootmgr} device boot description Boot Manager default {ntldr} displayorder {ntldr} {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} timeout 5 Windows Legacy OS Loader ------------------------ identifier {ntldr} device boot path \ntldr description Microsoft Windows XP Professional Windows Boot Loader ------------------- identifier {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions} path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE description MAINT osdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions} systemroot \WINDOWS detecthal Yes winpe Yes ...and after Sysprep: Windows Boot Manager -------------------- identifier {bootmgr} device boot description Boot Manager default {ntldr} displayorder {ntldr} {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} timeout 5 Windows Legacy OS Loader ------------------------ identifier {ntldr} device boot path \ntldr description Microsoft Windows XP Professional Windows Boot Loader ------------------- identifier {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} Does anyone have any thoughts on this? My initial C:\boot.ini has "timeout=5", but after Sysprep runs it has "timeout=30", so Sysprep is obviously doing something to modify the boot process, I just can't wrap my head around what it could do to my BCD.
  5. wscript.sleep() doesn't work in HTA, that's the problem.
  6. I'm writing an HTA whose body is broken down into tables with one of the top rows used for displaying status messages via a span. I'd like to include a 30 second countdown in the status before something automatically happens. Since HTA VBScript is too awesome to include a Sleep, I pause for 1 second by calling a subroutine that pings This works fine when I run it on XP, but when I run it in PE, the message doesn't automatically refresh unless there's mouse / touchpad activity, even if I replace the pings with a simple msgbox. Has anyone else seen this? Is there any solution to it? Below is some sample code. <html> <head> <title>Test</title> <HTA:APPLICATION ID="objTEST" APPLICATIONNAME="TEST" SCROLL="yes" SINGLEINSTANCE="yes" > </head> <script Language="VBScript"> Sub Window_OnLoad ShowCountdown 30 End Sub Sub ShowCountdown(howlong) For i = howlong To 0 Step -1 If i <> 0 Then status_msg.InnerHTML = "Device Imaging will begin in " & i & " seconds..." Else status_msg.InnerHTML = "Rebooting device to begin imaging..." End If DoSleep 1 Next End Sub Sub DoSleep(seconds) set oShell = CreateObject("Wscript.Shell") cmd = "%COMSPEC% /c ping -n " & 1 + seconds & ">nul" oShell.Run cmd,0,1 'msgbox "pause" End Sub </SCRIPT> <body> <table width="100%" border> <tr> <td ALIGN=CENTER HEIGHT=40 style="font-size:12pt;"><span id="status_msg"></span></td> </tr> </table> </body> </html>
  7. I'm working on a system that will use the Vista Boot Loader to either boot PE into RAM from a WIM on the C: drive, or boot into Win2K / XP on the D: drive using NTLDR. In my efforts to track down how to do this I looked in all of Microsoft's help and walkthroughs and several forum posts but I never found the whole thing at once. Well if you're trying to do the same thing I am, you're in luck, because I figured it out and thought I'd share. This also installs the Vista Boot Loader on a PC that didn't already have it. First create a bootable PE RAM image on CD or UFD that includes BOOTSECT.EXE in \Windows\System32\ and boot to it. The following commands assume C: is the primary, active partition, has been formatted, and has BOOT.INI, NTLDR, and NTDETECT.COM at the root. D: contains the Win2K / XP files. E: is the bootable media's drive letter. xcopy e:\boot\*.* /s /e /f c:\boot\ xcopy e:\sources\*.* /s /e /f c:\sources\ copy e:\bootmgr c:\ del c:\boot\bcd if not exist c:\temp md c:\temp bcdedit -createstore c:\temp\bcd bcdedit -store c:\temp\bcd -create {bootmgr} /d "Boot Manager" bcdedit -store c:\temp\bcd -set {bootmgr} device boot bcdedit -store c:\temp\bcd -create {ramdiskoptions} /d "WinPE" bcdedit -import c:\temp\bcd bcdedit -set {ramdiskoptions} ramdisksdidevice partition=c: bcdedit -set {ramdiskoptions} ramdisksdipath \boot\boot.sdi for /f "tokens=3" %%a in ('bcdedit -create /d "WinPE" -application osloader') do set guid=%%a bcdedit -set %guid% device ramdisk=[c:]\sources\boot.wim,{ramdiskoptions} bcdedit -set %guid% path \windows\system32\boot\winload.exe bcdedit -set %guid% osdevice ramdisk=[c:]\sources\boot.wim,{ramdiskoptions} bcdedit -set %guid% systemroot \windows bcdedit -set %guid% winpe yes bcdedit -set %guid% detecthal yes bcdedit -displayorder %guid% -addlast bcdedit -store c:\boot\bcd -create {ntldr} /d "Windows XP Professional" bcdedit -store c:\boot\bcd -set {ntldr} device boot bcdedit -store c:\boot\bcd -set {ntldr} path \ntldr bcdedit -store c:\boot\bcd -displayorder {ntldr} –addfirst bcdedit -store c:\boot\bcd -default {ntldr} bcdedit -store c:\boot\bcd -timeout 5 bootsect /nt60 c: "bootsect /nt60 c:" points the boot sector on C: to the Vista Boot Loader instead of NTLDR. All the Micro$oft documentation I've looked at has been missing \boot\ from the "path \windows\system32\boot\winload.exe" commands, and the WinPE help file that's supposed to show you how to create a bootable PE RAM disk on a hard drive doesn't tell you how to configure the boot loader. Hope this helps anyone who may be struggling with this stuff.
  8. Ok, I think I was using a bum CD because I created a new one by using the instructions in WINPE.CHM for "Walkthrough: Create a Custom Windows PE Image" step-by-step using "peimg /install=*" and now HTAs work like a champ. I think maybe the "peimg /prep" command might've been missed on that first CD as mshta.exe is now in X:\Windows\System32\ instead of that crazy X:\Windows\winsxs\... folder. Here's another question: In regards to placing a bootable PE partition on the hard drive. Does anyone have experience with password protecting PE? Is there any kind of built-in way to require a password to either boot or get into it? I'm guessing I'll have to add something to either startnet.cmd or my own HTA to accomplish this.
  9. I'm embarking on a project to replace our custom DOS-based system for deploying Windows with PE 2.0. BDD 2007 cannot accomplish everything we need, so I'd like to write all the scripts myself in HTA. I'll list my current issue first, and then everything I'd like to accomplish... Here's the issue I created a bootable PE 2.0 CD using the latest WAIK and installed all packages. After booting to the command prompt, I simply want to run an HTA that displays a window with "Hello world". If I just type "test.hta", it wants a file association. I find mshta.exe in some cryptic folder under X:\Windows\winsxs\..., so I copy that to X:\Windows\System32 and attempt "mshta.exe test.hta" with all forms of full paths and the like, but it just returns to the prompt and displays nothing. What do I have to do to manually run an HTA? What I'd like to accomplish Boot a PE CD without requiring "Press any key" Launch an HTA from startnet.cmd Install a bootable PE on C: Install XP Pro on D: with a WIM Provide a boot menu to choose between XP and PE Is any of this impossible? Would anyone be kind enough to offer some tips? Any help would be greatly appreciated. Now if I could just get the stupid HTA to run I'd feel like I'd won half the battle...

  • Create New...