Jump to content

Trouble Running VB script in PE 2.0


dkreifus

Recommended Posts

I've tried doing it without ntoskrnl.exe and the issue will persist. The original postings I found about the issue said to replace hal.dll, ntoskrnl.exe and ntkrnlpa.exe. I've found that only hal.dll and ntoskrnl.exe need to be replaced, but you're welcome to try it out as well.

Link to comment
Share on other sites


You've steered me right so far.

To my discredit...If I had read the first line of the VB script that Johan made..I might have understood better.

'// This script updates sysprep.inf with correct HAL Type

'// The Reference (master) computer should be built from

'// an Advanced ACPI computer

But my teachings always say to build from the most recent computer available.

Link to comment
Share on other sites

Just in case you're interested, here is some of the code from my solution. Note that it is in an HTA, so some of the vbscript calls are a little bit different as far as syntax goes. Oh yeah, just ignore the html stuff, its just informational messages to the user. I should also mention that the needHAL variable is set to 'yes' if acpipic is detected. The main stuff is in the handleHAL Sub.

'*****************************************************************************************
'* restoreBuild
'* starts the ghost restoration process for the selected build and method
'*****************************************************************************************
Sub restoreBuild
Dim filename, taskCmd

strTemp = "<h2>Restoring build...</h2>"
general.InnerHTML = strTemp

filename = cdrom & "\" & buildFilename
If not objFso.FileExists(filename) Then
strTemp = "<h2>ERROR: File not found " & filename & "</h2><ul>Ensure that <u><b>DISK 1</b></u> is loaded in the CD-ROM drive and click the " &_
"<i>Retry</i> button."
document.buttonsForm.nextButton.value = "<u>R</u>etry"
document.buttonsForm.nextButton.disabled = false
document.buttonsForm.cancelButton.disabled = false
general.InnerHTML = strTemp
Else
Select Case curMethod
Case "Initial"
taskCmd = "%comspec% /c ghost32.exe -sure -fdsp -clone,mode=load,src=" & filename & ",dst=1,szeL -fx > \ghost.log"
objShell.Run taskCmd,0,true
finishBuild
Case "Windows"
taskCmd = "%comspec% /c ghost32.exe -sure -fdsp -clone,mode=prestore,src=" & filename & ":1,dst=1:1,sze1=V -fx > \ghost.log"
objShell.Run taskCmd,0,true
finishBuild
End Select
End If
End Sub

'*****************************************************************************************
'* finishBuild
'* handles errors that occur during ghost and handles successful restorations
'*****************************************************************************************
Sub finishBuild
Dim result, logFile, count

Set logFile = objFso.GetFile("\ghost.log")
If logFile.Size <> "0" Then
Set logFile = objFso.OpenTextFile("\ghost.log")
count = 1
Do While logFile.AtEndOfStream <> true
result = result & count & "> "
Do While logFile.AtEndOfLine <> true or logFile.AtEndOfStream <> true
result = result & logFile.Read(1)
Loop
result = result & "<BR>"
general.InnerHTML = result
count = count + 1
Loop
logFile.Close
strTemp = "<CENTER><H1>FAILED</H1><DIV style='color:red;text-align:left'>An attempt to restore the system failed with the " &_
"following error message:<BR><BR><DIV style='position:absolute;border-style:solid;border-color:black;left:5%;" &_
"width:95%;color:black;padding:5%;border-width:1;font-family:terminal;font-size:10pt;overflow:auto'>" & result &_
"</DIV></DIV></CENTER>"
warning.InnerHTML = strTemp
warning.style.top = "10%"
warning.style.left = "10%"
warning.style.width = "80%"
warning.style.height = "75%"
document.buttonsForm.cancelButton.value = "E<u>x</u>it"
document.buttonsForm.cancelButton.accesskey = "x"
document.buttonsForm.cancelButton.disabled = false
warning.style.visibility = "visible"
Else
strTemp = "<h2>Complete!</h2><ul><font color=orange>" & result & "</font>The restoration process has finished without any " &_
"errors."
document.buttonsForm.cancelButton.value = "E<u>x</u>it"
document.buttonsForm.cancelButton.accesskey = "x"
document.buttonsForm.cancelButton.disabled = false
general.InnerHTML = strTemp
warning.style.visibility = "visible"
If needHAL = "yes" Then
handleHAL
Else
rebootMe
End If
End If
End Sub

'*****************************************************************************************
'* handleHAL
'* prepares the system for use with the correct HAL
'*****************************************************************************************
Sub handleHAL
Dim sysFolder, halFolder, strDest, inFile, outFile, line, words, lword
sysFolder = "C:\WINDOWS\System32"
halFolder = "X:\HAL"

strTemp = "<CENTER><H1>Updating HAL...</H1></CENTER>"
warning.InnerHTML = strTemp
objShell.Run "%comspec% /c diskpart /s X:\Windows\system32\probeParts.txt",0,true

Select Case strHAL
Case "acpipic"
If objFso.FolderExists(sysFolder) Then
strTemp = halFolder & "\halacpi.dll"
strDest = sysFolder & "\hal.dll"
objFso.CopyFile strTemp,strDest,true
strTemp = halFolder & "\ntoskrnl.exe"
strDest = sysFolder & "\ntoskrnl.exe"
objFso.CopyFile strTemp,strDest,true

'Remove UpdateUPHal line from sysprep.inf
strDest = "C:\sysprep\sysprep.inf"
If objFso.FileExists(strDest) Then
Set inFile = objFso.OpenTextFile(strDest,1,true)
Set outFile = objFso.CreateTextFile(strDest & ".tmp",true)
Do While inFile.AtEndOfStream <> true
line = inFile.ReadLine
If line <> "" Then
words = split(line,"=")
lword = trim(words(0))
If Lcase(lword) <> "updateuphal" Then
outFile.WriteLine(line)
End If
Else
outFile.WriteBlankLines(1)
End If
Loop
inFile.Close
outFile.Close
objFso.DeleteFile strDest,true
objFso.MoveFile strDest & ".tmp", strDest
End If
rebootMe
Else
strTemp = "<CENTER><H1>FAILED</H1><DIV style='color:red;text-align:left'>An attempt to update your system HAL has " &_
"failed due to an inaccessible system drive.</DIV></CENTER>"
warning.InnerHTML = strTemp
warning.style.top = "10%"
warning.style.left = "10%"
warning.style.width = "80%"
warning.style.height = "75%"
document.buttonsForm.cancelButton.value = "E<u>x</u>it"
document.buttonsForm.cancelButton.accesskey = "x"
document.buttonsForm.cancelButton.disabled = false
End If
Case Else
rebootMe
End Select
End Sub

'*****************************************************************************************
'* rebootMe
'* opens the CD tray, delays 8 seconds and reboots
'*****************************************************************************************
Sub rebootMe
'Open CD tray
strTemp = "<center><h1>Ejecting Media...</h1></center>"
warning.InnerHTML = strTemp
cdrom = cdrom & "\"
CreateObject("Shell.Application").Namespace(17).ParseName(cdrom).InvokeVerb("Eject")

'Give delay to allow disk to eject
objShell.Run "%comspec% /c cscript X:\Windows\system32\timer.vbs",0,true

'Reboot the system
strTemp = "<center><h1>Rebooting System...</h1></center>"
warning.InnerHTML = strTemp
objShell.Run "%comspec% /c wpeutil reboot",0,false
End Sub

Edited by zorphnog
Link to comment
Share on other sites

If sHalType(0) = "acpipic" Then

rename c:\windows\sytem32\hal.dll to hal.dll.old

rename c:\windows\sytem32\ntoskrnl.exe to ntoskrnl.exe.old

expand c:\i386\halacpi.dl_ -r c:\windows\sytem32\hal.dll

expand c:\i386\ntoskrnl.ex_ -r c:\windows\system32\ntoskrnl.exe

I think that should solve my problems

Edited by dkreifus
Link to comment
Share on other sites

You've steered me right so far.

To my discredit...If I had read the first line of the VB script that Johan made..I might have understood better.

'// This script updates sysprep.inf with correct HAL Type

'// The Reference (master) computer should be built from

'// an Advanced ACPI computer

But my teachings always say to build from the most recent computer available.

The computer you use has no bearing on the end result. Just change the HAL before you sysprep.

Link to comment
Share on other sites

oh my god! this is madness! like trtkron said....

just change the hal

and run the script

think about it when you change your apic_up or apic_mp hal to apic does it ask for installation files or does it do it automactically?

So where do you think these files come from?

This has never failed for me and I got 10 different laptops and 20+ Desktops.

Again I have never renamed any files nor copied them from CD or have an i386 anywhere near my images.

unless Johan Arwidmark MVP is wrong? maybe he is? all I know is he help me alot and his script and comments helped me consolidate all my images into one using ghost or wims.

@DKREIFUS

Please can you do a devcon on all your machines you want as one image. Then run Device hwids and I will knock up the script you need and the sysprep entries you need also for mass storage devices. if you like?

Link to comment
Share on other sites

ok say you have a machine that is....ACPI Uniprocessor PC", ACPI APIC UP HAL (Halaacpi.dll)

or...ACPI Multiprocessor PC", ACPI APIC MP HAL (Halmacpi.dll)

go into device manager and click on my computer and change the hal type to...

"Advanced Configuration and Power Interface (ACPI) PC", ACPI PIC HAL (Halacpi.dll)

this will not ask for any additional files. Sysprep your machine and then deploy to an..

"Advanced Configuration and Power Interface (ACPI) PC", ACPI PIC HAL (Halacpi.dll)

run either script from johan or trtkron within winpe.

there is no reason why this would not boot on a "Advanced Configuration and Power Interface (ACPI) PC"

The script would not make any changes to the sysprep.inf file as no change of hal is required.

Now try the same image onto a "ACPI Uniprocessor PC" and run the script this will update the unattend section of your sysprep and add the following "UpdateUPHAL = "ACPIAPIC_UP,%WINDIR%\Inf\Hal.inf"

now I know your wondering %windir%\inf does not contain my files well the files are taken from the dllcache folder.

Please put my mind at rest and try this lol

sorry If I come across a bit harsh I only mean to help :-)

Edited by p4ntb0y
Link to comment
Share on other sites

ok say you have a machine that is....ACPI Uniprocessor PC", ACPI APIC UP HAL (Halaacpi.dll)

or...ACPI Multiprocessor PC", ACPI APIC MP HAL (Halmacpi.dll)

go into device manager and click on my computer and change the hal type to...

"Advanced Configuration and Power Interface (ACPI) PC", ACPI PIC HAL (Halacpi.dll)

this will not ask for any additional files. Sysprep your machine and then deploy to an..

"Advanced Configuration and Power Interface (ACPI) PC", ACPI PIC HAL (Halacpi.dll)

run either script from johan or trtkron within winpe.

there is no reason why this would not boot on a "Advanced Configuration and Power Interface (ACPI) PC"

The script would not make any changes to the sysprep.inf file as no change of hal is required.

Now try the same image onto a "ACPI Uniprocessor PC" and run the script this will update the unattend section of your sysprep and add the following "UpdateUPHAL = "ACPIAPIC_UP,%WINDIR%\Inf\Hal.inf"

now I know your wondering %windir%\inf does not contain my files well the files are taken from the dllcache folder.

Please put my mind at rest and try this lol

sorry If I come across a bit harsh I only mean to help :-)

Yea..I understand. I did the HAL change this morning as a test on my computer, and I can do it. I'll be trying it shortly. Sadly, I don't know how to unseal an image, so I am updating my image, and doing a test today.

I don't know when I'll have the results. My apologies for not posting my HAL update earlier.

Is there a way to script the HAL change? I am trying to do a touchless unattended install as well

Edited by dkreifus
Link to comment
Share on other sites

@dkreifus

yes we can do lite touch ms speak.

How are you deploying your image.

is it wim based (file based)

or ghost (sector based)

we could boot winpe 2 and using the startnet.cmd add the cmd to cut your disk how you want it and then apply the image and then run ztihaldect.vbs.

your journey must near its end?

Not sure but you can sysprep a box three times good practice would be to capture the master first then do a sysprep.

Link to comment
Share on other sites

I am in the process of switching from Ghost based to WIM based so I can do the ztihaldetect script.

My process is an unattended installation, then I do some minor touching for applications. (some configs).

Then I run a script which logs out, logs in as a second account, copies the admin account to the default user account. Then it logs back in, deletes that 2nd account, and then syspreps the whole setup. (mass storage drivers and all).

I am switcing to using WIM now and PE2.0

When it loads up, it does sysprep, then logs in as admin. the user goes through a set of menu options which move the computer account to the right domain, install software based on the computer type (laptop, desktop), and then it reboots, cleans up, and reboots again for final use.

This is a very simplified understanding of my process.

My boot disk also lets the user choose their location, and deploys the image from different servers based on their location. (we're across the country)

Edited by dkreifus
Link to comment
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.
×
×
  • Create New...