CCTV Forum News
Use our miniPSS tool to get
enhanced hotkeys in PSS.
miniPSS is an EXE wrapper
for PSS on Windows XP/7.
Visit the Forum Post
Use our miniPSS tool to get
enhanced hotkeys in PSS.
miniPSS is an EXE wrapper
for PSS on Windows XP/7.
Visit the Forum Post
USB XP Setup
Information and Scripts
November 23rd, 2008
Information and Scripts
November 23rd, 2008
THIS IS OLD AND IS JUST LEFT HERE FOR REFERENCE.
Based off the USB_Multiboot.
If anything this will give you an idea on how to format and make a USB Drive to boot to XP Setup.
In this case im formatting and making the drive bootable without user intervention.
Optionally one could use HP USB Format Tool 2.06 or PEtoUSB.
I would say this is more geared towards other developers or advanced users.
A script to create the $WIN_NT$.~BT folder is listed further down this page.
Fixes are needed where setup deletes $WIN_NT$.~LS, $WIN_NT$.~BT, and TXTSETUP.SIF (See NOTES)
(if you use an SD card just lock it) as well as fixing the boot.ini, and sometimes assigning the USB drive
a letter other than C for the setup phase. The fixes included are all based off or from USB_Multiboot and
modified for the Eee PC in some cases.
Installing XP on the Eee PC with USB normally requires manually booting to the USB drive at least 3 times.
For some reason (at least on my 4G and another 2G) setting the USB drive as the first boot device in the
BIOS did not make it so. If you boot to the SSD during XP Setup using this method, you will get a HALL error.
If you want an easy way to install XP with USB then use the USB_Multiboot or another app, or even a USB CD/DVD.
** THIS IS FOR INFORMATION ONLY - USE AT YOUR OWN RISK **
READ ME
---------------
1 - Copy these files to the working folder:
===========================================
BootSect.exe - BootSect.exe
f16xpstp.bin - f16xpstp.bin (USB_Multiboot_10)
mkbt.exe - mkbt.exe (BARTPE FILE)
HPUSBF.EXE - (HP FILE)
NTDETECT.COM - XP Setup Source - \i386\
NTLDR - XP Setup Source - \i386\
SETUPLDR.BIN - XP Setup Source - \i386\
TXTSETUP.SIF - XP Setup Source - \i386\
boot.ini - Custom Boot.ini for USB Drive (see below)
The above are needed to boot to Windows XP Recovery Console.
Other files are included below but not used in the batch file as they are for XP Setup.
2 - Make Sub Folder called DOSFILES:
===========================================
Make 3 New Text Documents and Rename COMMAND.COM, IO.SYS, MSDOS.SYS.
Copy these to the DOSFILES folder. These are just used to trick the HP tool into thinking
they are real DOS boot files files and therefore making the drive bootable.
3 - RUN BATCH SCRIPT:
===========================================
Right click EDIT on .cmd file.
Change USBDRV value R: to the letter of your USB Drive.
Exit and Save then click on nt.cmd.
All files on drive will be deleted!!!
** MAKE SURE THE USB DRIVE LETTER IS CORRECT **
4 - Finalize:
===========================================
Copy $WIN_NT$.~BT Folder to USB Drive for Recovery Console or XP Setup.
To make this folder manually, open DOSNET.INF folder in XP Setup Source i386 folder.
Copy all Files listed under [FloppyFiles. and [RootBootFiles] to $WIN_NT$.~BT
Also copy the SYSTEM32 folder to $WIN_NT$.~BT, Eg. R:\$WIN_NT$.~BT\SYSTEM32\
Or use the script provided further down this page.
For XP Setup make new folder $WIN_NT$.~LS on USB Drive
Copy XP Setup Source i386 folder to $WIN_NT$.~LS on USB Drive
Eg. R:\$WIN_NT$.~LS\I386\
For XP Setup copy Winnt.sif to the $WIN_NT$.~BT folder (see below for Winnt.sif file)
5 - Notes:
===========================================
Windows format command must be available as it is used in this case.
$WIN_NT$.~LS, $WIN_NT$.~BT, and TXTSETUP.SIF are deleted at the end of XP setup
without providing batch file fixes called from Winnt.sif and using migrate.inf for write protection.
The Fix is where migrate.inf gives the USB Drive write protection during the initial stage of
setup, then $WIN_NT$.~LS, $WIN_NT$.~BT, and TXTSETUP.SIF are renamed at final phase of setup
so they are not deleted, and then at login they are renamed back to their original names.
(see below for files)
Another fix is to edit the boot.ini on the SSD so you can boot to the correct partition, otherwise
you will need to use the USB drive to boot to Windows XP on the SSD. This boot.ini differs from
the one that is placed on the USB drive. (see below for file)
Also without running MultiBoot_10's Migrate.inf batch file fix the SSD drive may not be assigned
drive C during XP Setup, though in my tests on the 701 it always gets C, and in the case of
the 701, a single drive PC, the USB gets D. So this is typically not needed for the Eee PC.
A basic migrate.inf is needed for write protection for the initial stage of setup. (see below for file)
The files we call from Winnt.sif are in this case copied to the System32 folder, and so we place them
in the $WIN_NT$.~LS\I386\ folder on the USB drive and add them to TXTSETUP.SIF in the root of the USB drive.
In the first rename batch file (USBREN1.CMD) the OEM files and folders are copied to their relative locations
on the SSD - this file is just a copy of the USB_Multiboot file called ren_fold.cmd.
$WIN_NT$.~BT folder is required for the boot to Windows XP Recovery Console.
If migrate.inf and winnt.sif exist in the $WIN_NT$.~BT folder remove them
if you just want to the recovery console else it may fail; leave it for an XP Setup.
BATCH FILE
------------------
Make new Text file and rename it something.cmd (whatever you want to name it, .cmd)
Right click EDIT then place the following into it, change the USB Drive letter, and save.
@echo off ::SET USB DRIVE LETTER SET USBDRV=R: CLS ECHO ALL FILES WILL BE DELETED ON USB DRIVE %USBDRV% ECHO CLICK THE [X] AT THE TOP RIGHT TO EXIT NOW OR ... PAUSE CLS IF NOT EXIST %USBDRV%\CON GOTO _ERR IF %USBDRV%==C: GOTO _ERR IF %USBDRV%==c: GOTO _ERR IF NOT EXIST DOSFILES\COMMAND.COM GOTO _ERR IF NOT EXIST DOSFILES\IO.SYS GOTO _ERR IF NOT EXIST DOSFILES\MSDOS.SYS GOTO _ERR format %USBDRV% /FS:FAT /q /u /backup /v:USBXP /x IF NOT EXIST HPUSBF.EXE GOTO _ERR HPUSBF %USBDRV% -FS:FAT -V:USBXP -B:DOSFILES -Y IF NOT EXIST BootSect.exe GOTO _ERR BootSect.exe /nt52 %USBDRV% /force DEL %USBDRV%\COMMAND.COM DEL %USBDRV%\*.* /f /q /a:RHS IF NOT EXIST ntdetect.com GOTO _ERR IF NOT EXIST setupldr.bin GOTO _ERR IF NOT EXIST TXTSETUP.SIF GOTO _ERR IF NOT EXIST ntldr GOTO _ERR copy /y ntdetect.com %USBDRV%\ntdetect.com copy /y setupldr.bin %USBDRV%\XPSTP copy /y TXTSETUP.SIF %USBDRV%\TXTSETUP.SIF copy /y ntldr %USBDRV%\ntldr IF NOT EXIST mkbt.exe GOTO _ERR IF NOT EXIST f16xpstp.bin GOTO _ERR IF NOT EXIST %USBDRV%\BTSEC\CON MD %USBDRV%\BTSEC mkbt.exe -x -c %USBDRV% %USBDRV%\BTSEC\BackUp.bs mkbt.exe -x f16xpstp.bin %USBDRV% mkbt.exe -x -c %USBDRV% %USBDRV%\BTSEC\XPSTP.bs mkbt.exe -x %USBDRV%\BTSEC\BackUp.bs %USBDRV% IF NOT EXIST boot.ini GOTO _ERR copy /y boot.ini %USBDRV%\boot.ini GOTO _EXIT :_ERR ECHO ERROR!! PAUSE EXIT :_EXIT ECHO Completed Okay PAUSE EXIT |
Boot.ini (for USB drive)
[Boot Loader] Timeout=10 Default=multi(0)disk(0)rdisk(1)partition(1)\WINDOWS [Operating Systems] C:\BTSEC\XPSTP.bs="Begin TXT Mode XP Setup, Never unplug USB-Drive (RUN ONCE)" multi(0)disk(0)rdisk(1)partition(1)\WINDOWS="Continue GUI XP Setup OR Start XP from SSD" /FASTDETECT |
THE FOLLOWING ARE ALL THE FIXES FOR XP SETUP
Winnt.sif - \$WIN_NT$.~BT\
TXTSETUP.SIF - \
USBREN1.CMD - \$WIN_NT$.~LS\I386\
USBREN2.CMD - \$WIN_NT$.~LS\I386\
EEEFIX.VBS - \$WIN_NT$.~LS\I386\
migrate.inf - \$WIN_NT$.~BT\
Winnt.sif basic: (for manual install, attended)
(msdosinitiated=1 gets rid of no CD rom error in text setup phase)
place in the $WIN_NT$.~BT folder
[Data] MsDosInitiated = 1 floppyless = 1 AutoPartition = 0 UnattendedInstall = "Yes" UseSignatures = "no" InstallDir = "\WINDOWS" EulaComplete = "1" winntupgrade = "no" win9xupgrade = "no" unattendswitch = "Yes" [GuiRunOnce] ;fix the boot.ini and rename back folders "%windir%\system32\usbren2.cmd" [SetupParams] ;rename folders so xp setup doesnt delete them UserExecute = "usbren1.cmd" |
Winnt.sif advanced: (for unattended)
(msdosinitiated=1 gets rid of no CD rom error in text setup phase)
place in the $WIN_NT$.~BT folder
[Data] MsDosInitiated = 1 floppyless = 1 AutoPartition = 0 UnattendedInstall = "Yes" UseSignatures = "no" InstallDir = "\WINDOWS" EulaComplete = "1" winntupgrade = "no" win9xupgrade = "no" unattendswitch = "Yes" [GuiUnattended] ;timezone -5 AdminPassword=* TimeZone=035 OEMSkipRegional=1 OemSkipWelcome=1 [UserData] ;enter your product key ProductKey="XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" ComputerName=EeePC FullName="Owner" [RegionalSettings] ;us english locals LanguageGroup=1 SystemLocale="0409" UserLocale="0409" UserLocale_DefaultUser="0409" InputLocale="0409:00000409" InputLocale_DefaultUser="0409:00000409" [Networking] InstallDefaultComponents=Yes [Identification] JoinWorkgroup="WORKGROUP" [Branding] BrandIEUsingUnattended=Yes [url];add your home page Home_Page=http://www.google.com [GuiRunOnce] ;fix the boot.ini and rename back folders "%windir%\system32\usbren2.cmd" [SetupParams] ;rename folders so xp setup doesnt delete them UserExecute = "usbren1.cmd" |
TXTSETUP.SIF:
this is the one that is copied to the root of the USB drive.
The files must be placed in $WIN_NT$.~LS\I386\ on the USB drive.
See below for more information on each file.
Replace:
[SourceDisksFiles] _default.pif = 1,,,,,,,1,2,0 |
With:
[SourceDisksFiles] USBREN1.CMD = 100,,,,,,_x,2,0,0 USBREN2.CMD = 100,,,,,,_x,2,0,0 EEEFIX.VBS = 100,,,,,,_x,2,0,0 _default.pif = 1,,,,,,,1,2,0 |
USBREN1.CMD:
(same as ren_fold.cmd in USB_Multiboot)
This renames $WIN_NT$.~LS, $WIN_NT$.~BT, and TXTSETUP.SIF during XP setup
to different backup names. This is called in Winnt.sif [SetupParams] section.
Also it copies any OEM files/folders.
@echo off SET USBDRIVE= SET TAGFILE=\$WIN_NT$.~BT :: First Limited Range to Prevent Windows No Drive Alert due to Cardreader :: For case of Repair Install when Drive not found, than Extended Range and :: Windows No Drive Alert - Press 4x Continue for Cardreader Drives FOR %%h IN (C D M N O P Q R S T U V W X Y) DO IF EXIST "%%h:%TAGFILE%" SET USBDRIVE=%%h: if "%USBDRIVE%" == "" ( FOR %%h IN (C D E F G H I J K L M N O P Q R S T U V W X Y) DO IF EXIST "%%h:%TAGFILE%" SET USBDRIVE=%%h: ) IF EXIST %usbdrive%\$WIN_NT$.~LS\$OEM$\$1\nul ( xcopy %usbdrive%\$WIN_NT$.~LS\$OEM$\$1\*.* "%systemdrive%\" /i /k /e /r /y /h ) IF EXIST %usbdrive%\$WIN_NT$.~LS\$OEM$\$$\nul ( xcopy %usbdrive%\$WIN_NT$.~LS\$OEM$\$$\*.* %systemroot% /i /k /e /r /y /h ) ren %USBDRIVE%\txtsetup.sif txtsetup.bak ren %USBDRIVE%\$WIN_NT$.~BT WIN_NT.BT ren %USBDRIVE%\$WIN_NT$.~LS WIN_NT.LS exit |
USBREN2.CMD:
(similar to undoren.cmd in USB_Multiboot)
This renames $WIN_NT$.~LS, $WIN_NT$.~BT, and TXTSETUP.SIF on login to windows
back to original names. This is called in Winnt.sif [GuiRunOnce] section.
Also included is the fix for the boot.ini for the Eee PC. (see below for EEEFIX.VBS)
The USB_Multiboot method doesnt seem to work with the Eee PC 701 on Windows Login.
On My Eee PC I get an Error that the drive is not ready, that being the SD Card slot (E).
ofcourse we could remove that from the search but we dont know if the user's USB drive is not E.
Therefore I made a VBscript that takes care of both restoring the folder and file names and
fixing the boot.ini.
@echo off IF NOT EXIST %windir%\system32\eeefix.vbs GOTO _cleanup ::######################################################### ::# # ::# FIX BOOT.INI # ::# # ::######################################################### :_fixboot Start /wait %windir%\system32\eeefix.vbs FIXBOOT ::######################################################### ::# # ::# RENAME FOLDERS ON USB DRIVE # ::# # ::######################################################### :_rename Start /wait %windir%\system32\eeefix.vbs RESTORE ::######################################################### ::# # ::# CLEANUP AND EXIT # ::# # ::######################################################### :_cleanup :: DELETE SYSTEM FILES IF EXIST %windir%\system32\eeefix.vbs del %windir%\system32\eeefix.vbs /q IF EXIST %windir%\system32\usbren1.cmd del %windir%\system32\usbren1.cmd /q IF EXIST %windir%\system32\usbren2.cmd del %windir%\system32\usbren2.cmd /q :_exit exit |
This is what the Boot.ini looks like for the Eee PC SSD
It may differ for PCs other than the 701, depending on the disk controller.
The VBScript file creates this in this case so we dont have to include it separately (see below)
[Boot Loader] timeout=30 Default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [Operating Systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows XP Professional" /noexecute=optin /fastdetect |
EEEFIX.VBS:
And here is the file that takes care of restoring the file and folder names and also creating the new boot.ini.
This script allows us to get the USB drive letter without any "Drive not ready" error messages.
I also added in a restart computer section but its not used in this case - could be useful for reg tweaks.
'
'==================================================
' Author: Rory Knowles
' Website: BahamasSecurity.com
' Date: August 11th, 2008
'--------------------------------------------------
'
Option Explicit
On Error Resume Next
Dim iArg
iArg = UCase(WScript.Arguments(0))
Select Case iArg
Case "FIXBOOT"
Call FixBootIni '// FIX BOOT.INI
Case "RESTORE"
Call RestoreFolders '// RESTORE USB SETUP FOLDERS
End Select
'==================================================
' FIX BOOT.INI
'==================================================
' EXAMPLE:
'--------------------------------------------------
' eeefix.vbs FIXBOOT
'==================================================
' Requirements:
'--------------------------------------------------
' Visual Basic Script Installed
' File System Object Installed
'--------------------------------------------------
Sub FixBootIni()
On Error Resume Next
Dim sRoot, sIni, sText, objFSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
sRoot = Left(objFSO.GetSpecialFolder(0), 3)
sIni = sRoot & "boot.ini"
sText = "[Boot Loader]" & vbCrLf & _
"timeout = 30" & vbCrLf & _
"Default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS" & vbCrLf & _
"[Operating Systems]" & vbCrLf & _
"multi(0)disk(0)rdisk(0)partition(1)\WINDOWS=""Windows XP Professional"" " & _
"/noexecute=optin /fastdetect"
If objFSO.FileExists(sIni) Then
Set objFile = objFSO.GetFile(sIni)
objFile.Attributes = 0
Set objFile = Nothing
objFSO.DeleteFile sIni
Set objFile = objFSO.OpenTextFile(sIni, 2, True)
objFile.Write sText
objFile.Close
Set objFile = Nothing
Set objFile = objFSO.GetFile(sIni)
objFile.Attributes = 4 Or 2
Set objFile = Nothing
End If
Set objFSO = Nothing
End Sub
'==================================================
' RESTORE XP SETUP FOLDERS
'==================================================
' EXAMPLE:
'--------------------------------------------------
' eeefix.vbs RESTORE
'==================================================
' Requirements:
'--------------------------------------------------
' Visual Basic Script Installed
' File System Object Installed
' WMI Service Enabled
' DCOM Service Enabled (for WMI)
'--------------------------------------------------
Sub RestoreFolders()
On Error Resume Next
'// DECLARATIONS
Dim objWMI, colDrives, objDrive
Dim objFSO, sTemp
'// CONSTANTS
Const BT_ORIG = "$WIN_NT$.~BT"
Const BT_BACK = "WIN_NT.BT"
Const LS_ORIG = "$WIN_NT$.~LS"
Const LS_BACK = "WIN_NT.LS"
Const TX_ORIG = "txtsetup.sif"
Const TX_BACK = "txtsetup.bak"
'// CREATE OBJECTS
Set objWMI = GetObject("winmgmts:")
Set colDrives = objWMI.ExecQuery("Select Name From Win32_LogicalDisk Where DriveType = 2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'// LOOP THROUGH REMOVABLE DRIVES
For Each objDrive In colDrives
'// DRIVE LETTER
sTemp = objDrive.Name
'// RESTORE
If objFSO.FolderExists(sTemp & "\" & BT_BACK) And _
objFSO.FolderExists(sTemp & "\" & LS_BACK) And _
objFSO.FileExists(sTemp & "\" & TX_BACK) Then
'// RESTORE XP SETUP FILES/FOLDERS
objFSO.MoveFolder sTemp & "\" & BT_BACK , sTemp & "\" & BT_ORIG
objFSO.MoveFolder sTemp & "\" & LS_BACK , sTemp & "\" & LS_ORIG
objFSO.MoveFile sTemp & "\" & TX_BACK , sTemp & "\" & TX_ORIG
Exit For
End If
Next
'// DESTROY OBJECTS
Set objFSO = Nothing
Set colDrives = Nothing
Set objWMI = Nothing
End Sub
|
Migrate.inf:
This gives the USB Drive write protection during the initial stage of setup.
Copy this to the $WIN_NT$.~BT folder on the USB drive, same location as the Winnt.sif file.
Optionally, if you want to set the USB drive a letter like U: for the XP setup, take a look in the
USB_Multiboot folders for MkMigrateInf2.cmd.
[Version] Signature = "$Windows NT$" [Addreg] ;WriteProtect USB HKLM,"SYSTEM\ControlSet001\Control\StorageDevicePolicies","WriteProtect",%REG_DWORD%,1 [Strings] ;Handy macro substitutions (non-localizable) REG_SZ = 0x00000000 REG_BINARY = 0x00000001 REG_DWORD = 0x00010001 REG_MULTI_SZ = 0x00010000 REG_SZ_APPEND = 0x00010008 REG_EXPAND_SZ = 0x00020000 |
VBScript to Make XP Setup Boot files and folder
Makes the $WIN_NT$.~BT Folder and root boot files based on the XP Setup Source you provide.
The files/folders are placed in the Scripts path inside a folder called $TEMP.
Whenever you run the Script, any previous files/folders are removed.
NOTE: No editing of the files is done in this script.
Call it from a batch file:
start /wait Make~BT.vbs "C:\XPSP2"
(start /wait is optional, that just waits for the script to exit)
Change The Source in the file;
Optionally edit the script to turn on messages and manually change the value of the Source:
This way you can just click on the file to run it, or no need to pass arguments from the batch file.
(comment out the existing line for possible future use)
'// SHOW MESSAGES
Const DEBUG_ON = True
'// XP SETUP SOURCE
'// eg. C:\XPSP2
'// Source = WScript.Arguments(0)
Source = "C:\XPSP2"
Make~BT.vbs
Option Explicit
'// DECLARATIONS
Dim Source, I386Path, TempPath
On Error Resume Next
'// SHOW MESSAGES
Const DEBUG_ON = False
'// XP SETUP SOURCE
'// eg. C:\XPSP2
Source = WScript.Arguments(0)
'// RUN SCRIPT
If Err = 0 And len(Source) > 3 Then
I386Path = Source & "\I386"
TempPath = ScriptPath & "\$TEMP"
Const DosNet = "DOSNET.INF"
Call MakeBTFolder
Else
'// SHOW ERROR
If DEBUG_ON = True Then
MsgBox "Source Error", vbCritical, "Make ~BT Folder"
End if
End If
'// PROCESS DOSNET
Sub MakeBTFolder()
'// DECLARATIONS
Dim sText, sRep, bRet: bRet = False
On Error Goto 0: On Error Resume Next
'// CLEAN PATHS
I386Path = RemoveMultiple(I386Path, "\\", "\")
TempPath = RemoveMultiple(TempPath, "\\", "\")
'// DELETE EXISTING TEMP FILES
Call RmDir(TempPath)
'// MAKE TEMP FOLDERS
Call MkDir(TempPath)
Call MkDir(TempPath & "\$WIN_NT$.~BT")
'// CHECK TEMP FOLDERS CREATED
If Not FolderExists(TempPath) Or Not FolderExists(TempPath & "\$WIN_NT$.~BT") Then
'// SHOW ERROR
If DEBUG_ON = True Then
MsgBox "Temp Folder Error", vbCritical, "Make ~BT Folder"
End if
Exit Sub
End if
'// PROCESS DOSNET BOOT FILES
If FileExists(I386Path & "\" & DosNet) Then
'// READ ENTIRE FILE TEXT
sText = Trim(ReadFile(I386Path & "\" & DosNet))
sText = RemoveMultiple(sText, vbCrLf & vbCrLf, vbCrLf)
If Len(sText) Then
If InStr(1, sText, "[Files]" & vbCrLf & "d1,usetup.exe,system32\smss.exe", 1) Then
sRep = StripText(sText, "[Files]", "[")
sText = Replace(sText, "[Files]" & sRep, "")
End If
If InStr(1, sText, "[Files]" & vbCrLf & "d1,usetup.exe,system32\smss.exe", 1) Then
sRep = StripText(sText, "[Files]", "[")
sText = Replace(sText, "[Files]" & sRep, "")
End If
sText = Replace(sText, "[", vbCrLf & "[")
sText = RemoveMultiple(sText, vbCrLf & vbCrLf & vbCrLf & "[", vbCrLf & vbCrLf & "[")
'// PROCESS SECTIONS - COPY FILES
If Len(sText) And Err = 0 Then
bRet = ProcessSections(sText, "FloppyFiles.", TempPath & "\$WIN_NT$.~BT")
If bRet Then bRet = ProcessSections(sText, "RootBootFiles", TempPath & "\")
End If
'// SHOW RESULT
If DEBUG_ON = True Then
'// RETURN OKAY
If bRet = True Then
MsgBox "Boot files created okay at " & TempPath, vbInformation, "Make ~BT Folder"
'// RETURN ERROR
Else
MsgBox "Error creating boot files", vbCritical, "Make ~BT Folder"
End If
End if
Else
'// SHOW ERROR
If DEBUG_ON = True Then
MsgBox "DOSNET.INF Corupt", vbCritical, "Make ~BT Folder"
End if
End If
Else
'// SHOW ERROR
If DEBUG_ON = True Then
MsgBox "DOSNET.INF Not Found in " & I386Path, vbCritical, "Make ~BT Folder"
End if
End IF
End Sub
'// PROCESS DOSNET SECTIONS
Function ProcessSections(ByVal sText, ByVal sSection, ByVal sDest)
'// DECLARATIONS
Dim sArr, i, j, bRet: bRet = False
Dim sTemp, sFile, iPos
Dim sExt, sNew, bTag
'// CLEAR ERRORS TO USE HERE
On Error Goto 0: On Error Resume Next
'// CHECK SECTION TEXT
If Len(sText) = 0 Or InStr(1, sText, "[" & sSection, 1) = 0 Then
ProcessSections = False
Exit Function
End If
'// CLEAN UP SECTION TEXT
sDest = sDest & "\"
sDest = RemoveMultiple(sDest, "\\", "\")
sText = Replace(sText, vbCrLf & "d1,", vbCrLf, 1, -1, 1)
sArr = Split(sText, vbCrLf)
'// LOOP THROUGH SECTION
j = UBound(sArr)
For i = 0 To j
sTemp = Trim(sArr(i))
If Left(sTemp, 1) = "[" And Right(sTemp, 1) = "]" Then
If InStr(1, sTemp, "[" & sSection, 1) Then
bTag = True
Else
bTag = False
End If
Else
If bTag = True Then
If Len(sTemp) > 0 And Left(sTemp, 1) <> ";" Then
'// IF WE NEED TO RENAME A FILE
If InStr(1, sTemp, ",") Then
sNew = Right(sTemp, Len(sTemp) - InStrRev(sTemp, ","))
sTemp = Replace(sTemp, sNew, "")
sTemp = Trim(Replace(sTemp, ",", ""))
End If
'// CHECK SOURCE FILE - IF EXISTS WE LEAVE AS IS
If FileExists(I386Path & "\" & sTemp) = False And InStr(1, sTemp, ".") > 0 Then
sExt = Right(sTemp, Len(sTemp) - InStrRev(sTemp, "."))
sTemp = Replace(sTemp, "." & sExt, ".")
If Len(sExt) > 2 Then
sExt = Left(sExt, Len(sExt) - 1) & "_"
Else
sExt = sExt & "_"
End If
sTemp = sTemp & sExt
End If
If Len(sNew) = 0 Then sNew = sTemp
'// COPY I386 FILE TO TEMP BOOT FOLDER
bRet = CopyFile(I386Path & "\" & sTemp, sDest & UCase(sNew))
If bRet = False Then Exit For
End If
End If
End If
sTemp = ""
sNew = ""
sExt = ""
If Err Then Exit For
Next
If Err Then
ProcessSections = False
Exit Function
End If
ProcessSections = bRet
End Function
'//=================================
'// COPY FILE AND CREATE SUB FOLDERS
'//---------------------------------
'// uses FileCopy Function (FSO)
'//---------------------------------
Function CopyFile(pSource, pDest)
On Error Resume Next
Dim sFile, sFolder, sRoot, sTemp
Dim sArr, x, y
'// SOURCE OR DEST ERRORS
If InStr(1, pSource, "\") <> 3 Or Len(pSource) < 4 Or FileExists(pSource) = False Or _
InStr(1, pDest, "\") <> 3 Or Len(pDest) < 4 Then
CopyFile = False
Exit Function
End If
sFile = Right(pDest, Len(pDest) - InStrRev(pDest, "\")) 'get dest file name
'// NO FILE NAME ERROR
If Len(sFile) = 0 Then
CopyFile = False
Exit Function
End If
'// HANDLE SUB FOLDERS NOW
sFolder = Trim(Replace(pDest, sFile, "")) 'get dest folder name
If Right(sFolder, 1) <> "\" Then sFolder = sFolder & "\" 'add trailing backslash
'// NO SUB FOLDER
If UBound(Split(sFolder, "\")) < 2 Then
'// COPY FILE NOW
CopyFile = FileCopy(pSource, pDest)
'// IS SUB FOLDER
ELSE
sRoot = Left(sFolder, 3) 'get drive root
sFolder = Replace(sFolder, sRoot, "") 'get folders only
sTemp = Replace(sRoot, "\", "") 'set root to var no backslash
sArr = Split(sFolder, "\") 'split sub folder backslashes
y = UBound(sArr)
If y > -1 Then 'if there are sub folders
For x = 0 To y 'loop through sub folders
If Len(sArr(x)) Then 'if not a blank subfolder eg. \\
sTemp = sTemp & "\" & sArr(x) 'add backslash to prev sub folder
'// MAKE SUB FOLDER IF NOT EXISTS
If Len(sTemp) > 3 And FolderExists(sTemp) = False Then
Call MkDir(sTemp)
End If
End If
sArr(x) = ""
Next
End If
'// COPY FILE NOW
CopyFile = FileCopy(pSource, pDest)
End if
End Function
'// REMOVE MULTIPLE ITEMS FROM TEXT
Function RemoveMultiple(ByVal myString, myVal, myRep)
On Error Resume Next
Do While (InStr(myString, myVal))
myString = Replace(myString, myVal, myRep, 1, -1, 1)
Loop
RemoveMultiple = myString
End Function
'// GET TEXT BETWEEN TEXT
Function StripText(ByVal pSource, ByVal start, ByVal finish)
Dim iPos, iPoe
On Error Resume Next
iPos = (InStr(1, pSource, start, 1) + Len(start))
iPoe = InStr(iPos, pSource, finish, 1)
StripText = Trim(Mid(pSource, iPos, (iPoe - iPos)))
End Function
'// GET THIS SCRIPT PATH
Function ScriptPath()
On Error Resume Next
ScriptPath = CreateObject("Scripting.FileSystemObject")._
GetParentFolderName(Wscript.ScriptFullName)
End Function
'// READ FILE TEXT
Function ReadFile(ByVal pFile)
On Error Resume Next
Dim objFSO, objFile
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(pFile) = True Then
Set objFile = objFSO.OpenTextFile(pFile, 1)
ReadFile = objFile.ReadAll
End If
Set objFile = Nothing
Set objFSO = Nothing
End Function
'// COPY A FILE
Function FileCopy(ByVal pFile1, ByVal pFile2)
On Error Resume Next
Dim objFSO, bRet: bRet = False
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(pFile1) = True Then
objFso.CopyFile pFile1, pFile2
bRet = objFSO.FileExists(pFile2)
End If
Set objFso = nothing
FileCopy = bRet
End Function
'// Create Folder
Function MkDir(ByVal pFolder)
On Error Resume Next
Dim objFSO, bRet: bRet = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(pFolder) = False Then
objFSO.CreateFolder(pFolder)
bRet = objFSO.FolderExists(pFolder)
End If
Set objFSO = Nothing
MkDir = bRet
End Function
'// Delete Folder
Function RmDir(ByVal pFolder)
On Error Resume Next
Dim objFSO, bRet: bRet = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(pFolder) = True Then
objFSO.DeleteFolder(pFolder)
bRet = objFSO.FolderExists(pFolder) <> True
End If
Set objFSO = Nothing
RmDir = bRet
End Function
'// FOLDER EXISTS
Function FolderExists(ByVal pFolder)
On Error Resume Next
Dim objFSO, bRet: bRet = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
bRet = objFSO.FolderExists(pFolder)
Set objFSO = Nothing
FolderExists = bRet
End Function
'// FILE EXISTS
Function FileExists(ByVal pFile)
On Error Resume Next
Dim objFSO, bRet: bRet = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
bRet = objFSO.FileExists(pFile)
Set objFSO = Nothing
FileExists = bRet
End Function
|
VBScript to Restore XP Setup Folder Names on USB Drive
Restores WIN_NT.BT, WIN_NT.LS, and TXTSETUP.BAK to $WIN_NT$.~BT, $WIN_NT$.~LS, and TXTSETUP.SIF.
Using the XP USB Setup (USB_Multiboot method) the file/folders are renamed during setup so XP Setup does not delete them.
They are then renamed back to their original names at the login to Windows.
If for some reason they are not named back, the following script will do this.
USBREN.VBS
'
'====================================
' Rename XP USB Setup Folders
'------------------------------------
' Author: Rory Knowles
' Website: BahamasSecurity.com
' Date: August 9th, 2008
'====================================
' Requirements:
'------------------------------------
' Visual Basic Script Installed
' File System Object Installed
' WMI Service Enabled
' DCOM Service Enabled (for WMI)
'====================================
'
Option Explicit
On Error Resume Next
'// DECLARATIONS
Dim objWMI, colDrives, objDrive
Dim objFSO, sTemp
'// CONSTANTS
Const BT_ORIG = "$WIN_NT$.~BT"
Const BT_BACK = "WIN_NT.BT"
Const LS_ORIG = "$WIN_NT$.~LS"
Const LS_BACK = "WIN_NT.LS"
Const TX_ORIG = "txtsetup.sif"
Const TX_BACK = "txtsetup.bak"
'// CREATE OBJECTS
Set objWMI = GetObject("winmgmts:")
Set colDrives = objWMI.ExecQuery("Select Name From Win32_LogicalDisk Where DriveType = 2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'// LOOP THROUGH REMOVABLE DRIVES
For Each objDrive In colDrives
'// DRIVE LETTER
sTemp = objDrive.Name
'// RESTORE
If objFSO.FolderExists(sTemp & "\" & BT_BACK) And _
objFSO.FolderExists(sTemp & "\" & LS_BACK) And _
objFSO.FileExists(sTemp & "\" & TX_BACK) Then
'// RESTORE XP SETUP FILES/FOLDERS
objFSO.MoveFolder sTemp & "\" & BT_BACK , sTemp & "\" & BT_ORIG
objFSO.MoveFolder sTemp & "\" & LS_BACK , sTemp & "\" & LS_ORIG
objFSO.MoveFile sTemp & "\" & TX_BACK , sTemp & "\" & TX_ORIG
Exit For
End If
Next
'// DESTROY OBJECTS
Set objFSO = Nothing
Set colDrives = Nothing
Set objWMI = Nothing
|
ADDING TWEAKS
This is just an example of how I add my tweaks.
There are other ways one can do this as well.
I keep this seperate from the system fixes.
OEM Folder on USB Drive:
$WIN_NT$.~LS\$OEM$
USBREN1.CMD (same as ren_fold.cmd in USB_Multiboot) copies the following during setup.
See above posts for the USBREN1.CMD file
$WIN_NT$.~LS\$OEM$\$1 - Copied to Root Drive Path
$WIN_NT$.~LS\$OEM$\$$ - Copied to Windows Path
Eg.
$WIN_NT$.~LS\$OEM$\$1\USBTMP - > C:\USBTMP
$WIN_NT$.~LS\$OEM$\$$\System32\MyFile.txt - > C:\Windows\System32\MyFile.txt
USBTMP
This is a folder I place my tweaks in. It is placed under $OEM$\$1 so it is copied to the system drive (c:)
I delete the folder once I am done with it.
Files used
Winnt.sif - $WIN_NT$.~BT\ as in prev post
Tweaks.cmd - $WIN_NT$.~LS\$OEM$\$1\USBTMP\
etwks.reg - Registry Tweaks - $WIN_NT$.~LS\$OEM$\$1\USBTMP\
hservs.exe - Services Tweaks - $WIN_NT$.~LS\$OEM$\$1\USBTMP\
hpkill.exe - Remove Page Files - $WIN_NT$.~LS\$OEM$\$1\USBTMP\
Restart.vbs - Restart Computer - $WIN_NT$.~LS\$OEM$\$$\System32\
NOTE: The Registry Tweak file is supplementary with my Nlite Setup.
When I get a chance I will add the Nlite tweaks into that as well.
Tweaks.cmd
The 3 tweaks I use require the system to be restarted before they take effect.
The PageKill program in particular requires the system to restart as it replaces
UserInit on restart so it can do its thing, then puts UserInit back and continues
to Windows. The 3 files/programs used in this tweak are linked below. They are
identical to the ones in my signature on the forum except they are silent.
If you use this file, you can edit the user settings for which tweak you want installed.
Optionally you could just remove or not include the file itself and it will be bypassed.
This batch file also deletes the USBTMP folder but you can disable that if you like.
@echo off :: user settings SET REGISTRY=true SET SERVICES=true SET KILLPAGE=true SET DELETEME=true :: system settings SET THISPATH=%systemdrive%\usbtmp SET REBOOTPC=false IF NOT EXIST %THISPATH%\CON GOTO _exit c: cd\ ::######################################################### ::# # ::# ANY CUSTOM COMMANDS OR PROGRAMS TO RUN # ::# # ::######################################################### :_custom :: ENTER YOUR COMMANDS HERE ::######################################################### ::# # ::# TWEAKS - REBOOT TO TAKE EFFECT # ::# # ::######################################################### :_registry IF NOT %REGISTRY%==true GOTO _services IF NOT EXIST %THISPATH%\etwks.reg GOTO _services ECHO Applying Registry Tweaks .. start /wait regedit.exe /s %THISPATH%\etwks.reg SET REBOOTPC=true :_services IF NOT %SERVICES%==true GOTO _killpage IF NOT EXIST %THISPATH%\hservs.exe GOTO _killpage ECHO Applying Services Tweaks .. start /wait %THISPATH%\hservs.exe /apply SET REBOOTPC=true :_killpage IF NOT %KILLPAGE%==true GOTO _reboot IF NOT EXIST %THISPATH%\hpkill.exe GOTO _reboot ECHO Removing Page Files .. start /wait %THISPATH%\hpkill.exe /apply SET REBOOTPC=true ::######################################################### ::# # ::# REMOVE THIS FOLDER AND RESTART COMPUTER # ::# # ::######################################################### :_reboot cd\ IF NOT %REBOOTPC%==true GOTO _cleanup IF NOT EXIST %windir%\system32\restart.vbs GOTO _cleanup IF NOT %DELETEME%==true GOTO _rebnor :_rebdel :: restart and delete folder start %windir%\system32\restart.vbs 1 "%THISPATH%" GOTO _exit :_rebnor :: restart but dont delete folder start %windir%\system32\restart.vbs 1 GOTO _exit ::######################################################### ::# # ::# REMOVE THIS FOLDER AND CONTINUE TO WINDOWS # ::# # ::######################################################### :_cleanup cd\ IF NOT %DELETEME%==true GOTO _exit Start /b %ComSpec% /cRD /s /q "%~dp0" :_exit exit |
Restart.vbs
Placed inside $WIN_NT$.~LS\$OEM$\$$\System32\ so it is copied to the System32 folder.
It requires an argument sent to it for it to work, even if that is 0.
It can also delete a folder or folders. In this case I use it to delete USBTMP.
As an example, in the Tweaks.cmd file I use: (where %THISPATH% is C:\USBTMP)
start %windir%\system32\restart.vbs 1 "%THISPATH%"
This file is left in the PC's System32 folder.
It is the only file that is not removed.
Option Explicit
Call RestartPC
'==================================================
' RESTART COMPUTER (optional delay & delete folder)
'==================================================
' EXAMPLE:
'--------------------------------------------------
'
' restart.vbs (no delay)
' restart.vbs 5 (5 sec delay)
'
' restart.vbs 1 "C:\USBTMP"
' (1 sec delay & delete c:\usbtmp)
'
' restart.vbs 3 "C:\USBTMP,C:\TMP2"
' (3 sec delay & delete c:\usbtmp\ & c:\tmp2\)
'
' restart.vbs 3 "C:\USBTMP,C:\TEST.TXT"
' (3 sec delay & delete c:\usbtmp\ & c:\TEST.TXT)
'
'==================================================
' Requirements:
'--------------------------------------------------
'
' Visual Basic Script Installed
' File System Object Installed
' Shutdown command installed
'
'--------------------------------------------------
Sub RestartPC()
On Error Resume Next
Dim objShell, objFSO, iDelay
Dim sArr, sDelete, sTemp, i
iDelay = Trim(WScript.Arguments(0))
If Len(iDelay) = 0 Then
MsgBox "Cannot Run without Command", vbCritical, "Restart Error"
Exit Sub
End If
'// GET FILES/FOLDER TO DELETE
sDelete = WScript.Arguments(1)
If Len(sDelete) Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
sArr = Split(sDelete, ",")
For i = 0 To UBound(sArr)
sTemp = Trim(sArr(i))
If objFSO.FolderExists(sTemp) = True Then
objFSO.DeleteFolder(sTemp)
ElseIf objFSO.FileExists(sTemp) = True Then
objFSO.DeleteFile(sTemp)
End If
Next
Set objFSO = Nothing
End If
'// DELAY
Wscript.Sleep Cint(iDelay) * 1000
Set objShell = CreateObject("WScript.Shell")
'// RESTART
objShell.Run "%comspec% /K shutdown -r -t 0", 0, False
Set objShell = Nothing
WScript.Quit
End Sub
|
Download Tweaks.zip
The zip file contains etwks.reg, hservs.exe, and hpkill.exe.
hservs.exe, and hpkill.exe are silent programs with no GUI. Download Now
Update Winnt.sif
[GuiRunOnce] ;fix the boot.ini and rename back folders "%windir%\system32\usbren2.cmd" ;custom batch files "%systemdrive%\usbtmp\tweaks.cmd" |
OPTIONAL - CMDLINES.TXT
Note. I dont use this in my case.
$WIN_NT$.~LS\$OEM$\CMDLINES.TXT
This file would contain the commands that GUI mode executes when installing optional components.
When the commands in Cmdlines.txt are carried out during Setup, there is no logged-on user.
See: unattended.msfn.org/unattended.xp/view/web/14/
ADDING DOS TOOLS - PART 1
It would be nice if we could have some DOS tools to create or delete partitions,
check the disk information, and totally restore the disk from an image file.
Even nicer if we could create that Asus Boot Booster partition at the same time.
TIP: Boot Booster basically caches part of the Bios so it skips the Logo and Bios checks.
Well here it is!
This will do all that and then some.
First we need to create a DOS Bootsector for Boot.ini.
IF YOU JUST WANT TO CREATE A DOS BOOTABLE USB DISK AND NOT USE BOOT.INI:
skip this part, use HP USB Format tool and make DOS start up disk with '98 boot files,
then goto part 2.
Also see this thread which uses XP boot disk files to create a bootable USB drive
and adds the disk tools (no 98 Boot files needed):
USB Disk Tools
This has been tested with the following Eee PCs:
Eee PC 701 - Single SSD (4GB)
Eee PC 1000 - Dual SSD Linux (8GB+32GB)
** THIS IS FOR INFORMATION ONLY - USE AT YOUR OWN RISK **
** NO PARTITIONING OR FORMATTING IS DONE IN THIS SCRIPT **
READ ME
------------------
1 - Copy these files to the working folder:
===========================================
f16msdos.bin - f16xpstp.bin (USB_Multiboot_10)
mkbt.exe - mkbt.exe (BARTPE FILE)
2 - RUN BATCH SCRIPT:
===========================================
Change USBDRV value R: to the letter of your USB Drive.
Exit and Save then click on Batch File.
** MAKE SURE THE USB DRIVE LETTER IS CORRECT **
3 - Copy these files to the root of the USB drive:
===========================================
COMMAND.COM - MS-DOS 98 Boot File
IO.SYS - MS-DOS 98 Boot File
MSDOS.SYS - MS-DOS 98 Boot File
NOTE: I could not get Windows ME DOS Boot files (the ones that come with XP) to boot to a bootsector file.
If someone else can get that to work please PM me. It seemed to be an error with the IO.sys in that case.
Otherwise for now Im using Win98 DOS boot files.
BATCH FILE
------------------
Make new Text file and rename it something.cmd (whatever you want to name it, .cmd)
Right click EDIT then place the following into it, change the USB Drive letter, and save.
@echo off ::SET USB USBDRV LETTER SET USBDRV=R: CLS ECHO THIS CREATES MSDOS BOOT SECTOR FOR THE USB DRIVE ECHO CLICK THE [X] AT THE TOP RIGHT TO EXIT NOW OR ... PAUSE CLS IF NOT EXIST %USBDRV%\CON GOTO _ERR IF %USBDRV%==C: GOTO _ERR IF %USBDRV%==c: GOTO _ERR IF NOT EXIST mkbt.exe GOTO _ERR IF NOT EXIST f16msdos.bin GOTO _ERR IF NOT EXIST %USBDRV%\btsec\CON MD %USBDRV%\btsec IF EXIST %USBDRV%\btsec\NTBOOT.bs DEL %USBDRV%\btsec\NTBOOT.bs IF EXIST %USBDRV%\btsec\MSBOOT.bs DEL %USBDRV%\btsec\MSBOOT.bs mkbt.exe -x -c %USBDRV% %USBDRV%\btsec\NTBOOT.bs mkbt.exe -x f16msdos.bin %USBDRV% mkbt.exe -x -c %USBDRV% %USBDRV%\btsec\MSBOOT.bs mkbt.exe -x %USBDRV%\btsec\NTBOOT.bs %USBDRV% DEL %USBDRV%\btsec\NTBOOT.bs GOTO _EXIT :_ERR ECHO ERROR!! PAUSE EXIT :_EXIT ECHO. ECHO Completed Okay PAUSE EXIT |
Edit Boot.ini
------------------------------
Open the boot.ini file on the USB Drive. Add this new line at the end:
C:\btsec\MSBOOT.bs="Boot to MS-DOS - Disk Management & Restore Options"
So the boot.ini may now look like this:
[Boot Loader] Timeout=10 Default=multi(0)disk(0)rdisk(1)partition(1)\WINDOWS [Operating Systems] C:\btsec\XPSTP.bs="Begin TXT Mode XP Setup, Never unplug USB-Drive (RUN ONCE)" multi(0)disk(0)rdisk(1)partition(1)\WINDOWS="Continue GUI XP Setup OR Start XP from SSD" /FASTDETECT C:\btsec\MSBOOT.bs="Boot to MS-DOS - Disk Management & Restore Options" |
ADDING DOS TOOLS - PART 2
I use a DOS shareware program called Aefdisk to handle the partitioning (ver1.7 for testing 2.2 is on website).
I use SnapShot for the disk imaging. You can download a time limited trial from the website listed below.
The backup feature stops working after a certain time but the restore always works.
First install XP and once you have it setup how you want it, use SnapShot within Windows
to create an image file of the C drive, and call it C-DRIVE.SNA
Then continue below.
This has been tested with the following Eee PCs:
Eee PC 701 - Single SSD (4GB)
Eee PC 1000 - Dual SSD Linux (8GB+32GB)
** THIS IS FOR INFORMATION ONLY - USE AT YOUR OWN RISK **
MAIN MENU
1-Disk Managment
2-Restore Disk Image
3-Exit to DOS
1-Disk Managment
---------------------
Delete Partitions
Create Single Partition
Create Partitions with Boot Booster
Install Standard DOS MBR loader
Show Disk Information
2-Restore Disk Image
----------------------
Restore from Image
Restore MBR from Image
Restore Partition Structure from Image
Restore Partition Structure and MBR from Image
Restore Complete Partition from Image
MENU DETAILS
Delete Partitions
----------------------
Deletes all Partitions on the first disk.
Installs Standard DOS MBR loader on the first disk.
Create Single Partition
------------------------------
Deletes all Partitions on the first disk.
Installs Standard DOS MBR loader on the first disk.
Creates a single NT Partition 1 of the total size of the first disk.
Create Partitions with Boot Booster
-----------------------------------------
Deletes all Partitions on the first disk.
Installs Standard DOS MBR loader on the first disk.
Creates an 8mb EFI Partition 2 at the end of the first disk.
Creates an NT Partition 1 of the remaining size of the first disk.
The EFI Partition is so that the BIOS Boot Booster feature is shown.
Boot Booster basically caches part of the Bios to that partition so when you boot
it skips the Asus Logo and Bios checks.
Do not enable Boot Booster in the BIOS until XP has been installed.
Install Standard DOS MBR loader
----------------------------------------
Installs Standard DOS MBR loader on the first disk.
Show Disk Information
------------------------
Shows Partition information for the first disk.
Shows Partition information for the USB disk.
Restore from Image
-------------------------
Restores a Partition on the first disk from an Image file.
Checks that the first disk is bootable, fixes if not.
Restore MBR from Image
--------------------------
Restores the first disk MBR from an Image file.
Restore Partition Structure from Image
------------------------------------------
Restores the first disk Partition Structure from an Image file.
Restore Partition Structure and MBR from Image
-------------------------------------------------
Restores the first disk Partition Structure from an Image file.
Restores the first disk MBR from an Image file.
Restore Complete Partition from Image
-----------------------------------------
Restores the first disk Partition Structure from an Image file.
Restores the first disk MBR from an Image file.
Restores a Partition on the first disk from an Image file.
Checks that the first disk is bootable, fixes if not.
DOS Command Options
Advanced users can exit to DOS and use any command line options.
Type AEFDISK/? for Disk Partitioning options.
Type SNAPSHOT/? for Disk Image Restore options.
READ ME
--------------
Copy these files to the root of the USB drive:
===============================================
Config.sys - See below
Autoexec.bat - See below
Logo.sys - Optional
Copy these files to a folder called DOS on the USB drive:
==========================================================
AEFDISK.EXE - Shareware (www.aefdisk.com) 1.7 tested
SNAPSHOT.EXE - Trial (www.drivesnapshot.de/en/index.htm)
C-DRIVE.SNA - Your SnapShot Image File
PART.BAT - See below
REST.BAT - See below
Config.sys
------------------
Make new Text file and rename it Config.sys
Right click EDIT then place the following into it.
[MENU] SUBMENU=PART0, Disk Management SUBMENU=REST0, Restore Image File MENUITEM=QUIT, Exit to DOS [PART0] MENUITEM=PART1, Delete Partitions MENUITEM=PART2, Create Single Partition MENUITEM=PART3, Create Partitions with Boot Booster MENUITEM=PART4, Install Standard DOS MBR loader MENUITEM=PART5, Show Disk Information SUBMENU=MENU, Back to Main Menu [REST0] MENUITEM=REST1, Restore from Image MENUITEM=REST2, Restore MBR from Image MENUITEM=REST3, Restore Partition Structure from Image MENUITEM=REST4, Restore Partition Structure and MBR from Image MENUITEM=REST5, Restore Complete Partition from Image SUBMENU=MENU, Back to Main Menu [PART1] [PART2] [PART3] [PART4] [PART5] [REST1] [REST2] [REST3] [REST4] [REST5] [QUIT] |
Autoexec.bat
------------------
Make new Text file and rename it Autoexec.bat
Right click EDIT then place the following into it.
@ECHO OFF CLS PROMPT=$P$G IF %CONFIG%=="" GOTO QUIT GOTO %CONFIG% :PART1 :PART2 :PART3 :PART4 :PART5 IF NOT EXIST DOS\PART.BAT GOTO QUIT CALL DOS\PART.BAT %CONFIG% GOTO QUIT :REST1 :REST2 :REST3 :REST4 :REST5 IF NOT EXIST DOS\REST.BAT GOTO QUIT CALL DOS\REST.BAT %CONFIG% :QUIT |
Logo.sys
------------------
This is optional. This replaces the default WINDOWS 98 LOGO.
Make a blank 0 length file and call it logo.sys
Part.bat
------------------
This is the file that deals with the Partitioning.
This primarily uses AEFDISK.
Settings can be changed for other PCs or Controllers.
Settings included are tested with the Eee PC 701 (4G)
@ECHO OFF PROMPT=$P$G CD\ ::================= :: USER SETTINGS ::----------------- SET srcdrv=c: SET srcnum=1 SET destnum=2 SET srcstr=USB SET deststr=Eee PC SET dospath=%srcdrv%\DOS ::================= :: SYSTEM SETTINGS ::----------------- SET partype=%1 SET delonly=false SET noboost=false SET booston=false SET mbronly=false SET msgpart="" SET endpart="" ::================= :: MENU SETTINGS ::----------------- IF %partype%=="" SET partype=PART1 IF %partype%==PART1 SET delonly=true IF %partype%==PART1 SET msgpart=Delete %deststr%Partitions IF %partype%==PART1 SET endpart=%deststr%Partitions Deleted IF %partype%==PART2 SET noboost=true IF %partype%==PART2 SET msgpart=Create Single %deststr%Partition IF %partype%==PART2 SET endpart=Single %deststr%Partition Created IF %partype%==PART3 SET booston=true IF %partype%==PART3 SET msgpart=Create %deststr%Partitions with Boot Booster IF %partype%==PART3 SET endpart=%deststr%Partitions with Boot Booster Created IF %partype%==PART4 SET mbronly=true IF %partype%==PART4 SET msgpart=Install Standard DOS MBR loader to %deststr% IF %partype%==PART4 SET endpart=Standard DOS MBR loaded to %deststr% ::######################################################### ::# # ::# CHECK DRIVES # ::# # ::######################################################### :_LOAD ::# CHECK SOURCE DRIVE IF EXIST %srcdrv%\windows\explorer.exe GOTO _ERRDRV IF NOT EXIST %dospath%\aefdisk.exe GOTO _ERRFILE SET ALLSIZE=0 SET freesize=0 PATH=%dospath%\;%srcdrv%\ ::# CHECK DEST DISK NUM EXISTS AEFDISK %destnum% /ALLSIZE IF %ALLSIZE%==0 GOTO _ERRDISK ::######################################################### ::# # ::# PARTITION MENU # ::# # ::######################################################### :_PARTMNU ::# SHOW DISK PARTITION INFO ONLY IF %partype%==PART5 GOTO _SHOWINF CLS ECHO %msgpart% ECHO ALL FILES WILL BE DELETED!!! ECHO. PAUSE GOTO _PARTDEL ::######################################################### ::# # ::# PARTITION PROCESS # ::# # ::######################################################### :_PARTDEL CLS IF %mbronly%==true GOTO _PARTMBR ::# DELETE ALL PARTITIONS AEFDISK %destnum% /delall ECHO. ::# GET FREESIZE SET freesize=0 AEFDISK %destnum% /freesize :_PARTMBR ::# LOAD STANDARD MBR AEFDISK %destnum% /MBR ECHO. IF %delonly%==true GOTO _PARTEND IF %mbronly%==true GOTO _PARTEND IF %noboost%==true GOTO _NOBOOST :_BOOSTON ::# CREATE PARTITION 2 WITH EF AND 7mb (8mb) AEFDISK %destnum% /pri:7:EF:2 ECHO. ::# GET FREESIZE FOR PARTITION 1 SET freesize=0 AEFDISK %destnum% /freesize ::# DELETE ALL PARTITIONS AGAIN AEFDISK %destnum% /delall ECHO. ::# CREATE PARTITION 1 WITH NT AND FREESIZE ::# CREATE PARTITION 2 WITH EF AND 7mb (8mb) AEFDISK %destnum% /pri:%freesize%:07:1 /pri:7:EF:2 ECHO. AEFDISK %destnum% /activate:1 ECHO. GOTO _PARTEND :_NOBOOST ::# CREATE PARTITION 1 WITH NT AND TOTAL SIZE AEFDISK %destnum% /pri:0:07 ECHO. :_PARTEND ::# SHOW THE PROCESS END MESSAGE ECHO ----------------------------------------------------- ECHO %endpart% IF %delonly%==true ECHO Unpartitioned - %freesize% MB Available IF %noboost%==true ECHO Created Partition - Windows NT %freesize% MB IF %booston%==true ECHO Created Partition1 - Windows NT %freesize% MB IF %booston%==true ECHO Created Partition2 - Boot Booster EFI 8 MB ECHO ----------------------------------------------------- :_REBOOT ::# SHOW REBOOT MESSAGE ECHO Press CTL-ALT-DEL to reboot PAUSE >NUL CLS GOTO _REBOOT ::######################################################### ::# # ::# SHOW DISK INFO # ::# # ::######################################################### :_SHOWINF CLS ECHO %deststr%Disk Info: AEFDISK %destnum% /show AEFDISK %destnum% /info ECHO. ECHO ----------------------------------------------------- SET freesize=0 AEFDISK %destnum% /freesize ECHO TOTAL FREE SPACE: %freesize% MB ECHO ----------------------------------------------------- ECHO Press any key to show %srcstr% disk info . . . ECHO Press CTL-ALT-DEL to reboot PAUSE >NUL :_SHOWUSB CLS ECHO %srcstr% Disk Info: AEFDISK %srcnum% /show AEFDISK %srcnum% /info ECHO. ECHO ----------------------------------------------------- ECHO Press any key to show %deststr%disk info . . . ECHO Press CTL-ALT-DEL to reboot PAUSE >NUL GOTO _SHOWINF ::######################################################### ::# # ::# ERROR MESSAGES # ::# # ::######################################################### :_ERRDRV CLS ECHO ============================================================================= ECHO **** ERROR - SOURCE DRIVE NOT SUPPORTED **** ECHO ============================================================================= PAUSE GOTO _EXIT :_ERRDISK CLS ECHO ============================================================================= ECHO **** ERROR - SYSTEM DISK NOT FOUND **** ECHO ============================================================================= PAUSE GOTO _EXIT :_ERRFILE CLS ECHO ============================================================================= ECHO **** ERROR - SOURCE FILE CORUPT OR MISSING **** ECHO ============================================================================= PAUSE GOTO _EXIT ::######################################################### ::# # ::# EXIT TO DOS # ::# # ::######################################################### :_EXIT CLS |
Rest.bat
------------------
This is the file that deals with the Image Restore.
This primarily uses SNAPSHOT but also uses AEFDISK.
Settings can be changed for other PCs or Controllers.
Settings included are tested with the Eee PC 701 (4G)
@ECHO OFF PROMPT=$P$G CD\ ::================= :: USER SETTINGS ::----------------- SET srcdrv=c: SET destnum=2 SET destdrv=HD2 SET srcstr=USB SET deststr=Eee PC SET imgfile=C-DRIVE SET dospath=%srcdrv%\DOS SET imgpath=%dospath% ::================= :: SYSTEM SETTINGS ::----------------- SET restype=%1 SET resonly=false SET mbronly=false SET partonly=false SET partmbr=false SET msgrest="" SET endrest="" ::================= :: MENU SETTINGS ::----------------- IF %restype%=="" SET restype=REST1 IF %restype%==REST1 SET resonly=true IF %restype%==REST1 SET msgrest=Restore %deststr%from Image IF %restype%==REST1 SET endrest=%deststr%Restore Complete IF %restype%==REST2 SET mbronly=true IF %restype%==REST2 SET msgrest=Restore %deststr%MBR from Image IF %restype%==REST2 SET endrest=%deststr%MBR Restore Complete IF %restype%==REST3 SET partonly=true IF %restype%==REST3 SET msgrest=Restore %deststr%Partition Structure from Image IF %restype%==REST3 SET endrest=%deststr%Partition Structure Restore Complete IF %restype%==REST4 SET partmbr=true IF %restype%==REST4 SET msgrest=Restore %deststr%Partition Structure and MBR from Image IF %restype%==REST4 SET endrest=%deststr%Partition Structure and MBR Restore Complete IF %restype%==REST5 SET msgrest=Restore %deststr%Complete Partition from Image IF %restype%==REST5 SET endrest=%deststr%Complete Partition Restore Complete ::######################################################### ::# # ::# CHECK DRIVES # ::# # ::######################################################### :_LOAD ::# CHECK SOURCE DRIVE IF EXIST %srcdrv%\windows\explorer.exe GOTO _ERRDRV IF NOT EXIST %imgpath%\%imgfile%.SNA GOTO _ERRFILE IF NOT EXIST %dospath%\snapshot.exe GOTO _ERRFILE IF NOT EXIST %dospath%\aefdisk.exe GOTO _ERRFILE SET ALLSIZE=0 PATH=%dospath%\;%srcdrv%\ ::# CHECK DEST DISK NUM EXISTS AEFDISK %destnum% /ALLSIZE IF %ALLSIZE%==0 GOTO _ERRDISK SET ALLSIZE=0 ::######################################################### ::# # ::# RESTORE MENU # ::# # ::######################################################### :_RESTMNU CLS ECHO %msgrest% ECHO ALL FILES WILL BE DELETED!!! ECHO. PAUSE GOTO _RESTPAR ::######################################################### ::# # ::# RESTORE DISK # ::# # ::######################################################### :_RESTPAR IF %resonly%==true GOTO _RESTORE IF %mbronly%==true GOTO _RESTMBR SNAPSHOT RESTORE %destdrv% partitionstructure %imgpath%\%imgfile%.SNA -Y IF %partonly%==true GOTO _RESTEND :_RESTMBR SNAPSHOT RESTORE %destdrv% MBR %imgpath%\%imgfile%.SNA -Y IF %mbronly%==true GOTO _RESTEND IF %partmbr%==true GOTO _RESTEND :_RESTORE SNAPSHOT RESTORE %destdrv% auto %imgpath%\%imgfile%.SNA -Y SNAPSHOT CHECKBOOT %destdrv% -Y :_RESTEND ECHO ----------------------------------------------------- ECHO %endrest% :_REBOOT ECHO Press CTL-ALT-DEL to Reboot PAUSE >NUL CLS GOTO _REBOOT ::######################################################### ::# # ::# ERROR MESSAGES # ::# # ::######################################################### :_ERRDRV CLS ECHO ============================================================================= ECHO **** ERROR - SOURCE DRIVE NOT SUPPORTED **** ECHO ============================================================================= PAUSE GOTO _EXIT :_ERRDISK CLS ECHO ============================================================================= ECHO **** ERROR - SYSTEM DISK NOT FOUND **** ECHO ============================================================================= PAUSE GOTO _EXIT :_ERRFILE CLS ECHO ============================================================================= ECHO **** ERROR - SOURCE FILE CORUPT OR MISSING **** ECHO ============================================================================= PAUSE GOTO _EXIT ::######################################################### ::# # ::# EXIT TO DOS # ::# # ::######################################################### :_EXIT CLS |
CREDITS
None of this would be possible without the terrific work by the members over on the MSFN forums:
www.msfn.org/board/forum/157-install-windows-from-usb
Also, without Microsoft ofcourse we wouldn't even be installing Windows XP to begin with.

