Explanations:
errWhere - Variable to store the Where are we atm part of error reporting.
SetCommentString - function to store the "whats going on atm" part of error reporting and possibly copy to log file under certain situations.
StillLoading - Boolean to let other functions ignore anything that gets set right now.
initLogging - Starts up the logging process and tells it where to go.
logMessage - self explanatory
initCommandlineArguments - reads the command line arguments and sets bool values and such.
Code: Select all
Public Sub PrimaryInit()
On Error GoTo ErrHandler
errWhere = "APInitialize.PrimaryInit()"
100 SetCommentString vbCrLf & "Trying to initialize.", Verbose
StillLoading = True
102 initLogging app.Path & "\autopatcher.log"
AppVerStr = app.Major & "." & app.Minor & "." & app.Revision
logMessage "Autopatcher v" & AppVerStr & " Has Started at " & Now & vbCrLf
104 logMessage "Starting Autopatcher From " & app.Path & vbCrLf
106 SetCommentString vbCrLf & "Trying to get commandline arguments.", DebugOnly
108 initCommandlineArguments
110 SetCommentString vbCrLf & "Trying to get operating system specifics.", DebugOnly
111 Set FSO = CreateObject("Scripting.FileSystemObject")
'check if GetSpecialFolder works. Doesn't work on Windows 2008 R2 64-bit?
If Not FSO.FolderExists(FSO.GetSpecialFolder(0)) Then
'Its Not Working... Check Registry
Set TheFolders.windows = FSO.GetFolder(getKeyValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "SystemRoot", True))
Else
112 Set TheFolders.windows = FSO.GetSpecialFolder(0)
End If
114 If Len(TheFolders.windows.Path) < 4 Then
ManualSetError = True
errDescription = "Windows Folder NOT Found."
GoTo ErrHandler
End If
If FSO.FolderExists(FSO.GetSpecialFolder(1)) Then
116 Set TheFolders.system = FSO.GetSpecialFolder(1)
Else
Set TheFolders.system = FSO.GetFolder("c:\") ' set it to root so path len will fail Len check doesn't work if uninitialised
End If
118 If Len(TheFolders.system.Path) < 4 Then
ManualSetError = True
errDescription = "System Folder NOT Found."
GoTo ErrHandler
End If
120 Set TheFolders.system32 = FSO.GetFolder(TheFolders.windows & "\System32")
122 If Len(TheFolders.system32.Path) < 4 Then
ManualSetError = True
errDescription = "System32 or Syswow64 Folder NOT Found."
GoTo ErrHandler
End If