gDMSS
2.6 for Android
gDMSS-T 2.5 for Android
iDMSS HD 1.0 for iPad
iDMSS-T 2.5 for iOS
DAV Batch Converter
all new results..
Your Ad here
gDMSS-T 2.5 for Android
iDMSS HD 1.0 for iPad
iDMSS-T 2.5 for iOS
DAV Batch Converter
all new results..
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
|

