Tripredacus

[Project] Windows PE as a recovery partition

35 posts in this topic

I'm going to drop my task list in this thread to help me track my progress. It may have been easier to have done this earlier, as I am almost finished with the alpha version.

Current issues:

1. Repair and Full recovery buttons do not launch their helper HTAs properly. MSHTA is executed but the HTA does not appear. Testing in VM fails script processing because the VM is running XP Pro and not WinPE.

Currently, repair and full HTA files are untested as to whether or not they actually work.

2. Command prompt authenticator box stays open after cmd.exe is launched.

3. Display resolution issue has possible fix, see here:

http://www.msfn.org/board/index.php?showtopic=134244

4. Need to change restart button to open a OK/Cancel msgbox instead of a standard OK box. This way if the user clicks the button by accident they won't be forced to reboot even if they cancel.

5. Go through the "corporate test" meaning showing the software to management. I am currently using example branding items, such as a place to put a company logo and corporate copyright information. Also need to approve all colors, verbiage, and boot process wording, blah blah blah. Also determine final recovery partition size, currently using 14GB!

For a general update, all current testing is being done on an MSI Wind model netbook. It has been a tough transition for me. Basically this all started one day because I was bored and wanted to figure out a solution to making a recovery partition for Vista, since we aren't going to upgrade our SoftThinks software for it. And I did it in the demo version of Flash. I had previously written software in Flash so I didn't need more than 30 days to do it. So it came under the attention of the bigwigs and they want me to work on it for real. Well, for real meant I couldn't use Flash (not because it was the demo) because we don't have a license for it. I think we have Photoshop but that's it from Adobe, maybe Acrobat. Anyways so I had to take my perfectly working and horrible looking idea and switch "engines" and make it nice looking and flawless. Well since I am only (currently) down to the five problems above, I think I am almost done. I think my first problem list was like 20+ and that didn't count my week or so trying to figure out how to use the MBR!

0

Share this post


Link to post
Share on other sites
1. Repair and Full recovery buttons do not launch their helper HTAs properly. MSHTA is executed but the HTA does not appear. Testing in VM fails script processing because the VM is running XP Pro and not WinPE.

How are you launching these other HTAs? A shell object.run command? If so, make sure the first parameter isn't 0 or the window will be hidden (ex. objShell.Run cmd, 0, 0) Are you running them by just using the command "FILENAME.HTA" or are you using "mshta.exe FILENAME.HTA"? Are you putting a "%comspec% /c" in front of it?

2. Command prompt authenticator box stays open after cmd.exe is launched.

Is this a pop-up box or within the HTA's HTML? If it's in the HTML you should be able to use a div or span area and just replace its contents when you launch your cmd.exe.

4. Need to change restart button to open a OK/Cancel msgbox instead of a standard OK box. This way if the user clicks the button by accident they won't be forced to reboot even if they cancel.

This should be easy enough to fix with something like valAnswer = msgbox("Do you really want to reboot now?", vbYesNo,"Reboot?")...if valAnswer=vbYes...if valAnswer=vbNo

0

Share this post


Link to post
Share on other sites

I have a plan for most of those items. The HTA launching issue is in a thread in the programming forum. I am using a method from other programs I have used so am expecting the same results... maybe I am missing a peice there.

http://www.msfn.org/board/index.php?showtopic=134164

The ok/cancel box is not something I need help on, its just on my checklist.

As far as the password prompt, its because I have to change how I have the code arranged. Currently, after the correct credentials are typed in, it launches a program, cmd.exe. However, I need to wrap that into a funtion and add exit() to that function only. Previously I tried putting it at the end of the script but it just would taskkill itself :yes: It is written in AutoIT.

I forgot an additional item, need to take into effect the Realtek Card Reader issue.

http://www.msfn.org/board/index.php?showtopic=134398

0

Share this post


Link to post
Share on other sites

I just replied to that thread you linked for the card reader. Maybe some of that code would be useful to you.

0

Share this post


Link to post
Share on other sites

Revised restart.exe code in AutoIT.

Switch MsgBox(1, "Restart", "You have chosen to restart the computer. Click OK to continue.")
Case 1;OK pressed
RunWait (@ComSpec & " /c c:\mbr 0 1 /h")
RunWait (@ComSpec & " /c x:\windows\system32\wpeutil reboot")
Case 2;CANCEL pressed
Exit()
EndSwitch

Note that it does more than restart. It hides the recovery partition again... and I forgot that the recovery partition will appear as the C Drive, so the drive letter changing script isn't going to work for me in this case. I will have to do a lot of pilot testing to verify that the recovery partition is always the C Drive. The Card Reader issue may only appear during deployment and not during recovery, and if this is the case then I'm not going to have to worry about it. It has already been accepted that if the recovery partition fails to work in the field, it will come back on RMA to get redone anyways. This is good news at least!

Now here is a big issue. When the recovery partition loads, it resets the MBR via winpeshl.ini. This is required otherwise after the restart, it won't go back to the system partition. One of my concerns is a big "what if" such as a user boots into the recovery partition and then powers off the machine, the battery dies, etc. This will leave the recovery partition visible in Windows which is a big no-no. I may end up having it hide the partition during winpeshl.ini as well to eliminate this issue. Any ideas about this possible problem?

I'll work on the admin prompt code after lunch and hopefully post a revised version of that as well.

I wanted to add that I've found an additional issue. While testing to see how Windows sees the recovery partition, I realised that it is possible for the end user to delete the partition from Disk Management. Any ideas of how I can change the image so that this option is not available?

Here is the test code for the admin prompt. Also in AutoIT. It hasn't been tested but it passes Beta Compile.

$GUI = GUICreate("Login",210,80,-1,-1,0x16C80000,0x00000181)
$USERNAME = GUICtrlCreateInput("Username",5,5,200,20,0x01)
$PASSWORD = GUICtrlCreateInput("Password",5,30,200,20,0x21)
$LOGIN = GUICtrlCreateButton("Login",50,55,100,20)
GUISetState(@SW_SHOW,$GUI)

While 1
$MSG = GUIGetMsg()
If $MSG = $LOGIN Then
If GUICtrlRead($USERNAME) == "username" And GUICtrlRead($PASSWORD) == "password" Then
Run(@Comspec & " /c cmd.exe")
Exit
Else
MsgBox(0,"Login","Incorrect username or password.")
EndIf
ElseIf $MSG = -3 Then
Exit
EndIf
WEnd

Exit

0

Share this post


Link to post
Share on other sites

An interesting development regarding launching the HTA from a button. Let's consider the following: I can launch an HTA via winpeshl.ini using mshta, but i can't use it from the button. Here is the main difference, winpeshl.ini code:

%SYSTEMDRIVE%\Windows\System32\mshta.exe, "%SYSTEMDRIVE%\Windows\System32\recovery1024x600.hta"

compared to before, the difference is the full path there. I tested by trying to launch an HTA using MSHTA from CMD but it would not open. It would only open once the full path argument was used. I am guessing that this is because MSHTA uses a relative path from its location, rather than the location from where the command is run from. Think PHP includes, the idea is similar!

I'm going to run a recompile after using the full path and see how that goes.

0

Share this post


Link to post
Share on other sites

Recovery for full is failing. Script Error generated "Internet Explorer Script Error"

That is to say, the same line of ObjShell.run "command",0,True works to do other things, like starting the recovery process itself. NOTE: forgot to declare the variable

Also, the setres command that works in XP is still not working in the PE. It works fine for standard displays, so I know it isn't the fault of the PE. In my experience, peimg the display driver doesn't work because PE will still use the standard display driver. Any more ideas?

Also, DXtransforms do not work in the PE either. ie:

filter:progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#E2E2E2',EndColorStr='#6e6e6e);

Full Recovery now works, but something fails in the recovery process. Windows generates a registry error just before it enters Welcome... this is getting so close now!

0

Share this post


Link to post
Share on other sites

The registry error at that first boot usually means the partition that you installed the image on was not formatted before the image is installed. I've seen that a handful of times.

I don't have any experience with setres or using winpeshl.ini, but you don't need to use MSHTA.EXE to launch an HTA file from a batch file like startnet.cmd, PE will launch it by association to the full path if you just execute the HTA file name.

0

Share this post


Link to post
Share on other sites

The full recovery just runs diskpart with a script so perhaps it is possible that the diskpart script is failing. However, if I launch the command prompt and run the commands manually that the script executes, including the same syntax, it works fine. So the VBScript is not working properly OR it starts running imagex BEFORE diskpart is finished.

0

Share this post


Link to post
Share on other sites

I've had that happen on occasion. I redirect the output from my diskpart commands to log files and when that happened I think it said the disk wasn't ready so I added routines to loop waiting for disk readiness to be reported in WMI.

0

Share this post


Link to post
Share on other sites

OK so here is the function in the VBScript. It runs imagex just fine but obviously it is failing to run diskpart. I doubt the reason it fails is because of the fully qualified path. But maybe I should try it out?

   	Set objShell = CreateObject("WScript.Shell")
ObjShell.run "cmd /c x:\windows\system32\diskpart /s x:\windows\system32\full_diskpart.txt",0,True
ObjShell.run "cmd /c imagex /apply c:\sp1.wim 1 d:",0,True

Or perhaps its the cmc /c interacts different with diskpart than with imagex? Any other ideas? I'll compare to my deployment code to see if I can find any differences. Actually my other code (I didn't write it) uses the following:

ObjShell.run("&chr(34) & "cmd /c diskpart /s" & chr(34) &" &chr(32) & TempTXT)

As you can see it uses a var called TempTXT but I am not going to use a var. Also I don't quite understand the chr(34) usage.

0

Share this post


Link to post
Share on other sites

Riddle me this Batman! I got it all functional at last.

This does not work:

ObjShell.run "cmd /c x:\windows\system32\diskpart /s x:\windows\system32\full_diskpart.txt",0,True

This works:

ObjShell.run "cmd /c diskpart /s x:\windows\system32\full_diskpart.txt",0,True

Strange... Now I am back to GUI stuff again, and after that figue out a deployment process.

0

Share this post


Link to post
Share on other sites

I am still ocassionally getting this error. I am going to try to recreate it so I can make a note as to what it says. I set up a separate test environment on a DQ45CB board for our other guy to test out. There is a major difference between the Intel board and the Wind. The Wind will recover a sysprepped image. The Intel board will recover an Audit mode image.

Also, another annoying this is that sometimes (about as sometimes as the imaging error), the PE doesn't rehide the partition after recovering. This only has happened after a successful recovery, and not during one of those ones that failed. It may also be a "disk not ready" issue, so I'm going to have to add some redundancy into the scripts...

Fatal Error

An error has been encountered that prevents Setup from continuing.

Windows is unable to start because the registry could not be updated. To address this problem, please contact your computer manufacturer. Windows must now Shut Down.

Press OK to view the Setup log file

Clicking OK reboots the computer. So far it seems like this is the operation of events, and appears to be reproducable.

1. A working model with XP on C and recovery partition hidden.

2. Boot into recovery, run a full recovery (that formats the C drive, or D drive actually)

... wait

I found major errors here. First on the Wind, the size that the recovery formats the C drive is wrong. Also on the Intel board, the recovery formats the entire drive, deleting the recovery partition... :realmad:

I can do this manually. What seems to be happening is that when Diskpart creates the partition, initially it is 130GB which is fine, but after reboot it becomes 60GB

select disk 0
select vol d
delete vol
create part pri
select part 1
active
assign letter=d
format fs=ntfs quick
exit

Afterwards, using list vol I get the following:

Volume 0	 D	 NTFS	Partition	135 GB	Healthy
Volume 1 C NTFS Partition 14 GB Healthy
Volume 2 E Removable 0 GB No Media

then dropped the image. It of course WORKED this time. :angry: and go through welcome and let it boot into Windows again. AND NOW IT WORKS.

On a side note, while the drive size is correct and XP didn't blow up, the recovery partition has a drive letter assigned to it. I have the PE actually hide the partition TWICE. Once during winpeshl.ini and again in between formatting the partition and imaging. So I have these three scenarios that seem to happen BECAUSE of certain situations.

Situation 1

- Windows does not error out before welcome

- the system partition size is correct

- the recovery partition is not hidden and is assigned a drive letter

- I then hide the partition and reboot into recovery

Situation 2

- Windows errors out

- after reboot into Recovery, diskpart shows the system partition to be 60GB.

- run recovery again

Situation 3

- Windows does not error out.

- the system partition is 60GB in Windows

- the recovery partition is hidden

These happen in that order each time, never had them work in any other order. If I recovery AGAIN after Situation 3, it loops and it will start at 1 again. I am really stumped.

Edited by Tripredacus
0

Share this post


Link to post
Share on other sites

Here are some related articles.

http://support.microsoft.com/kb/818171

I can't see how this could be related. For one, I am not using RTM, but SP2. Also this only happens 33% of the time, so it doesn't explain the times when it works. And most articles about this error seem related to sysprep, however the actual problem is definately in the (re)deployment phase.

0

Share this post


Link to post
Share on other sites

Normal testing is complete at this point, as I may have found the cause of the problem. Our regular XP unattend (which I used to create the recovery image) uses a WINBOM.INI file that OOBE may be processing incorrectly. I cannot post this file, but I have my two log files that I have been compiling.

Full statistics report of recovery partition behaviour. 

Product: MSI Wind Netbook MS-N0111X-044US
OS: Windows XP Pro SP2 sysprepped
partition: Windows PE 2.1 with custom apps
RAM: 1GB SODIMM
HDD: Toshiba Mobile 160GB

Different scenarios outlined below:

Situation 1
- Windows does not error out before welcome
- the system partition size is correct
- the recovery partition is not hidden and is assigned a drive letter
- I then hide the partition and reboot into recovery

Situation 2
- Fatal Error: Windows is unable to start because the registry could not be updated.
- Recovery partition is hidden
- System partition is 61GB in PE/Diskpart
- WINBOM file is created in sysprep, see winbomfiles.txt

Situation 3
- Windows does not error out.
- the system partition is 61GB in Windows
- the recovery partition is hidden

### Timeline of events.

06-09-2009 (earlier) reflected situation 1
06-09-2009 15:45 - situation 3
06-09-2009 16:04 - situation 3
06-10-2009 08:55 - situation 3
06-10-2009 09:10 - situation 2
06-10-2009 09:57 - situation 2

UPDATE: modifying recovery image to remove information from the WINBOM.INI file.

and winbomfiles.txt so far:

WINBOM FILE #1

WINBOM FILE #2
Factory is using the following WinBOM.ini file: C:\sysprep\WINBOM.INI
ERROR: Factory state "Preparing for automatic logon" failed.
Application ".NET Framework 1.1" returned exit code 0.
Application ".NET 1.1 Framework SP1 Update" returned exit code 3010.
Application "NDP1.1sp1-KB886903-X86" returned exit code 3010.
Application ".NET 2.0" returned exit code 0.
Application "NDP20-KB917283-X86.exe" returned exit code 0.
Application "NDP20-KB922770-X86.exe" returned exit code 0.
Application "Malicious Software Removal Tool" returned exit code 0.
Application "WindowsXP-KB885835-x86-ENU" returned exit code 0.
Application "Windows-KB913433-x86-ENU.exe" returned exit code 0.
Application "WindowsXP-KB923789-x86-ENU.exe" returned exit code 0.
Application "Updates" returned exit code 0.
Factory is using the following WinBOM.ini file: C:\sysprep\WINBOM.INI
ERROR: Factory state "Preparing for automatic logon" failed.
Factory is using the following WinBOM.ini file: C:\sysprep\WINBOM.INI
ERROR: Factory state "Preparing for automatic logon" failed.
Factory is using the following WinBOM.ini file: C:\sysprep\WINBOM.INI
ERROR: Factory state "Preparing for automatic logon" failed.
Factory is using the following WinBOM.ini file: C:\sysprep\WINBOM.INI
ERROR: Factory state "Preparing for automatic logon" failed.
ERROR: Could not locate WinBOM.ini on any removable drives or the system drive.

WINBOM FILE #3

At this point, I will have to totally reimage the drive because I can't copy the WIM off the recovery partition. Its too big (1.3GB) and I didn't enable networking in the PE.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.