Jump to content

[Solved] Decode & edit VBE file


Recommended Posts

1st I need to edit the autoExec.vbe file in the package, but it first needs to be decrypted

http://cdgenp01.csd.toshiba.com/content/support/downloads/MEUpdate71521176.exe

2nd I need to remove the ac/battery check (its preventing install)

1424ifp.png

Edit: I managed to decode it using this, now could somebody help edit the vbs to remove the PowerCheck?

With WScript
Set objWshShell = .CreateObject("WScript.Shell")
Set objFS = .CreateObject("Scripting.FileSystemObject")
End With

Const strDefLangId = "0409"
Const strLogFileExt = ".log"

Const strParamFileExt = ".prm"
Const strOwnerSect = "owner"
Const strLangIdKey = "langid"
Const strAdminKey = "admin"

Const strSMSParam = "/sms"
Const strAutoParam = "/auto"
Const strForceParam = "/force"
Const strAnyOSParam = "/anyos"
Const strDebugParam = "/debug"

Const strIniFileExt = ".ini"
Const strFirmwareSect = "Firmware"
Const strTitleKey = "Title"
Const strReadMeFileKey = "ReadMeFile"
Const strReadMeAFileKey = "ReadMeAFile"
Const strReadMeSFileKey = "ReadMeSFile"
Const strNewFWKey = "NewFW"
Const strOldFWKey = "OldFW"
Const strAMTStEnKey = "AMTStEn"
Const strAMTStDsKey = "AMTStDs"
Const strInfoExeNameKey = "InfoExeName"
Const strInfoExeParamFvKey = "InfoExeParamFv"
Const strInfoExeParamIaKey = "InfoExeParamIa"
Const strUpdtExeNameKey = "UpdtExeName"
Const strUpdtExeParamAMKey = "UpdtExeParamAM"
Const strUpdtExeParamNAKey = "UpdtExeParamNA"
Const strUpdtExeParamAMRKey = "UpdtExeParamAMR"
Const strUpdtExeParamNARKey = "UpdtExeParamNAR"

'----------------------------------------------------------------------'

debugMode = False
fDoClean = True

exitCode = 0

fSMSMode = False
fAutoMode = False
fForceMode = False
fAnyOSMode = False
fDebugMode = False

Dim strMessage(13)

fAdmin = False
LangID = strDefLangId
ReadMeText = ""
ExecButton = POPUP_BUTTON1
CloseButton = POPUP_BUTTON2
fPowerOK = False

PopupTitle = ""

strTitle = ""
strReadMeFile = ""
strReadMeAFile = ""
strReadMeSFile = ""
strNewFW = ""
aryOldFW = Empty
strAMTStEn = ""
strAMTStDs = ""
strInfoExeName = ""
strInfoExeParamFv = ""
strInfoExeParamIa = ""
strUpdtExeName = ""
strUpdtExeParamAM = ""
strUpdtExeParamNA = ""
strUpdtExeParamAMR = ""
strUpdtExeParamNAR = ""

Set objHelper = Nothing
Set objMsgBox = Nothing

myPath = WScript.ScriptFullName
With objFS
myFolder = .GetParentFolderName(myPath)
myName = .GetFileName(myPath)
ParamFile = .BuildPath(myFolder, .GetBaseName(myName) & strParamFileExt)
IniFile = .BuildPath(myFolder, .GetBaseName(myName) & strIniFileExt)
End With

curFolder = objWshShell.CurrentDirectory
objWshShell.CurrentDirectory = myFolder

If debugMode Then PopupMsg "myPath = " & myPath & vbCrLf & _
"myFolder = " & myFolder & vbCrLf & _
"myName = " & myName & vbCrLf & _
"ParamFile = " & ParamFile & vbCrLf & _
"IniFile = " & IniFile & vbCrLf & _
"curFolder = " & curFolder

'----------------------------------------------------------------------'
' Arguments '
'----------------------------------------------------------------------'

With WScript
If .Arguments.Count > 0 Then
For i = 0 To .Arguments.Count - 1
arg = .Arguments(i)
LCarg = LCase(arg)
If LCarg = strSMSParam Then
fSMSMode = True
If debugMode Then PopupMsg "fSMSMode = " & fSMSMode
ElseIf LCarg = strAutoParam Then
fAutoMode = True
If debugMode Then PopupMsg "fAutoMode = " & fAutoMode
ElseIf LCarg = strForceParam Then
fForceMode = True
If debugMode Then PopupMsg "fForceMode = " & fForceMode
ElseIf LCarg = strAnyOSParam Then
fAnyOSMode = True
If debugMode Then PopupMsg "fAnyOSMode = " & fAnyOSMode
ElseIf LCarg = strDebugParam Then
fDebugMode = True
If debugMode Then PopupMsg "fDebugMode = " & fDebugMode
End If
Next
End If
End With

'----------------------------------------------------------------------'
' Exec '
'----------------------------------------------------------------------'

If debugMode Then PopupMsg "Exec..."

With New CIniFile
If .Open(ParamFile) Then
If .SectionExists(strOwnerSect) Then
If .ValueExists(strOwnerSect, strLangIdKey) Then LangID = .ReadValue(strOwnerSect, strLangIdKey)
If .ValueExists(strOwnerSect, strAdminKey) Then fAdmin = .ReadBool(strOwnerSect, strAdminKey)
End If
.Close
End If
End With

If debugMode Then PopupMsg ParamFile & vbCrLf & _
" LangID = " & LangID & vbCrLf & _
" fAdmin = " & fAdmin

TranslateMessages

If exitCode = 0 Then
With New CIniFile
If .Open(IniFile) Then
If .SectionExists(strFirmwareSect) Then
strTitle = .ReadValue(strFirmwareSect, strTitleKey)
strReadMeFile = .ReadValue(strFirmwareSect, strReadMeFileKey)
strReadMeAFile = .ReadValue(strFirmwareSect, strReadMeAFileKey)
strReadMeSFile = .ReadValue(strFirmwareSect, strReadMeSFileKey)
strNewFW = .ReadValue(strFirmwareSect, strNewFWKey)
aryOldFW = Split(.ReadValue(strFirmwareSect, strOldFWKey), ",")
strAMTStEn = .ReadValue(strFirmwareSect, strAMTStEnKey)
strAMTStDs = .ReadValue(strFirmwareSect, strAMTStDsKey)
strInfoExeName = .ReadValue(strFirmwareSect, strInfoExeNameKey)
strInfoExeParamFv = .ReadValue(strFirmwareSect, strInfoExeParamFvKey)
strInfoExeParamIa = .ReadValue(strFirmwareSect, strInfoExeParamIaKey)
strUpdtExeName = .ReadValue(strFirmwareSect, strUpdtExeNameKey)
strUpdtExeParamAM = .ReadValue(strFirmwareSect, strUpdtExeParamAMKey)
strUpdtExeParamNA = .ReadValue(strFirmwareSect, strUpdtExeParamNAKey)
strUpdtExeParamAMR = .ReadValue(strFirmwareSect, strUpdtExeParamAMRKey)
strUpdtExeParamNAR = .ReadValue(strFirmwareSect, strUpdtExeParamNARKey)
End If
.Close
PopupTitle = strTitle
Else
exitCode = 1
End If
End With

If exitCode = 0 Then
With objFS
InfoExe = .BuildPath(myFolder, strInfoExeName)
UpdtExe = .BuildPath(myFolder, strUpdtExeName)
LogFile = .BuildPath(myFolder, .GetBaseName(strUpdtExeName) & strLogFileExt)
If (Not .FileExists(InfoExe)) Or (Not .FileExists(UpdtExe)) then exitCode = 1
End With
If debugMode Then PopupMsg "InfoExe = " & InfoExe & vbCrLf & _
"UpdtExe = " & UpdtExe & vbCrLf & _
"LogFile = " & LogFile
End If

If exitCode <> 0 Then
PopupErrMsg strMessage(10)
End If
End If

If exitCode = 0 Then
OStype = GetOStype
If debugMode Then PopupMsg "OStype = " & OStype

If fDebugMode Then
PopupTitle = "[DEBUG] " & strTitle
PopupMsg "OS Type : " & OStype & vbCrLf & _
"Lang ID : " & LangID & vbCrLf & _
"Admin : " & fAdmin & vbCrLf & _
"SMS Mode : " & fSMSMode & vbCrLf & _
"Auto Mode : " & fAutoMode & vbCrLf & _
"Force Mode : " & fForceMode & vbCrLf & _
"Any OS Mode : " & fAnyOSMode & vbCrLf
PopupTitle = strTitle
End If

If Not fAnyOSMode Then
Select Case OStype
Case "WinXP"
exitCode = 0
Case "WinVista"
exitCode = 0
Case "Win7"
exitCode = 0
Case "WinSvr2003"
exitCode = 0
Case Else
exitCode = 1
End Select
If exitCode <> 0 Then
PopupErrMsg strMessage(1)
End If
End If
End If

If exitCode = 0 Then
If Not fAdmin Then
PopupErrMsg strMessage(2)
exitCode = 1
End If
End If

If exitCode = 0 Then
Set objHelper = New CTosWshHelper
If Not objHelper.Activated Then
Set objHelper = Nothing
PopupErrMsg strMessage(10)
exitCode = 1
End If
End If

If (exitCode = 0) And (Not fForceMode) Then
exitCode = CheckFW(strNewFW, strInfoExeParamFv)

If exitCode <> 0 Then
For i = LBound(aryOldFW) To UBound(aryOldFW)
exitCode = CheckFW(aryOldFW(i), strInfoExeParamFv)
If exitCode = 0 Then Exit For
Next

If exitCode <> 0 Then
Set objHelper = Nothing
PopupInfoMsg strMessage(8)
End If

Else
Set objHelper = Nothing
PopupInfoMsg strMessage(9)
exitCode = 1
End If
End If

If exitCode = 0 Then
exitCode = 1

With objFS
ReadMeFile = .BuildPath(myFolder, .GetBaseName(strReadMeFile) & "." & LangID)
If Not .FileExists(ReadMeFile) then ReadMeFile = .BuildPath(myFolder, strReadMeFile)
If .FileExists(ReadMeFile) Then
With .OpenTextFile(ReadMeFile)
ReadMeText = .ReadAll
.Close
End With
End If
End With

fPowerOK = objHelper.PowerCheck
Set objMsgBox = objHelper.CreatePopup
If objHelper.IsPopup(objMsgBox) Then
With objMsgBox
.Property("Width") = 620
.Property("Height") = 400
.Property("Title") = PopupTitle
.Property("BaseColor") = vbWhite
.ButtonAdd strMessage(11)
.ButtonAdd strMessage(12)
.FontStyle "Message", , , "FixedSys", 9
.Message = ReadMeText
.Property("NoticeHeight") = 32
.FontStyle "Notice", vbRed, FONT_STYLE_BOLD + FONT_STYLE_BLINK
.Notice = strMessage(3)
If Not fPowerOK Then
.ButtonEnable(ExecButton) = False
.NoticeEnable = True
End If
.Open
End With
exitCode = 0
End If
End If

If (exitCode = 0) And ((Not fPowerOK) Or (Not fSMSMode) Or (Not fAutoMode)) Then
With objMsgBox
Do
.Sleep 1000, True
ButtonClick = .ButtonClick
If OnButtonClick(ButtonClick, CloseButton) Then
.Close
exitCode = 1
Else
If fPowerOK Then
If Not objHelper.PowerCheck Then
fPowerOK = False
.ButtonEnable(ExecButton) = False
.NoticeEnable = True
End If
Else
If objHelper.PowerCheck Then
.NoticeEnable = False
.ButtonEnable(ExecButton) = True
fPowerOK = True
End If
End If
End If
Loop Until (exitCode <> 0) Or (fPowerOK And (OnButtonClick(ButtonClick, ExecButton) Or fSMSMode Or fAutoMode))
End With
End If

If exitCode = 0 Then

If fSMSMode Then
With objFS
ReadMeSFile = .BuildPath(myFolder, .GetBaseName(strReadMeSFile) & "." & LangID)
If Not .FileExists(ReadMeSFile) then ReadMeSFile = .BuildPath(myFolder, strReadMeSFile)
If .FileExists(ReadMeSFile) Then
With .OpenTextFile(ReadMeSFile)
ReadMeText = .ReadAll
.Close
End With
End If
End With
Else
With objFS
ReadMeAFile = .BuildPath(myFolder, .GetBaseName(strReadMeAFile) & "." & LangID)
If Not .FileExists(ReadMeAFile) then ReadMeAFile = .BuildPath(myFolder, strReadMeAFile)
If .FileExists(ReadMeAFile) Then
With .OpenTextFile(ReadMeAFile)
ReadMeText = .ReadAll
.Close
End With
End If
End With
End If

With objMsgBox
.ButtonEnable(ExecButton) = False
.ButtonEnable(CloseButton) = False
.Message = ReadMeText
.NoticeEnable = False
.FontStyle "Notice", vbBlue, FONT_STYLE_BOLD + FONT_STYLE_BLINK
.Notice = strMessage(4)
.NoticeEnable = True
End With

exeParam = ""
addParam exeParam, UpdtExe, False
exitCode = CheckFW(strAMTStEn, strInfoExeParamIa)
If exitCode = 0 Then
If (Not fSMSMode) then
exeParam = exeParam & " " & strUpdtExeParamAMR
Else
exeParam = exeParam & " " & strUpdtExeParamAM
End If
Else
exitCode = CheckFW(strAMTStDs, strInfoExeParamIa)
If exitCode = 0 Then
If (Not fSMSMode) then
exeParam = exeParam & " " & strUpdtExeParamAMR
Else
exeParam = exeParam & " " & strUpdtExeParamAM
End If
Else
If (Not SMSMode) then
exeParam = exeParam & " " & strUpdtExeParamNAR
Else
exeParam = exeParam & " " & strUpdtExeParamNA
End If
End If
End If
If debugMode Then PopupMsg "exeParam = [" & exeParam & "]"

With objFS.OpenTextFile(LogFile, 2, True)
.WriteLine "-- Start -- " & Now()
.Close
End With
strLog = ""

With objHelper.CreateProcess
.Exec exeParam, False, True
Do While .Status = 0
objMsgBox.Sleep 100
str = .StdOut
StdErr = .StdErr
If StdErr <> "" Then
If str <> "" Then str = str & vbCrLf
str = str & StdErr
End If
If str <> "" Then
strLog = strLog & str
End If
Loop
exitCode = .ExitCode

str = .StdOut
StdErr = .StdErr
If StdErr <> "" Then
If str <> "" Then str = str & vbCrLf
str = str & StdErr
End If
If str <> "" Then
strLog = strLog & str
End If
End With

With objFS.OpenTextFile(logFile, 8, True)
.Write strLog
.WriteLine "--- End --- " & Now()
.Close
End With

If debugMode Then PopupMsg "ExitCode = " & exitCode
If fDebugMode Then
PopupTitle = "[DEBUG] " & strTitle
PopupMsg exeParam & vbCrLf & vbCrLf & "-> Exit Code = " & exitCode & vbCrLf & vbCrLf & _
"---- Log ----" & vbCrLf & strLog & vbCrLf & "-------------"
PopupTitle = strTitle
End If

If exitCode = 0 Then
With objMsgBox
.FontStyle "Notice", RGB(0, 172, 0), FONT_STYLE_BOLD
.Notice = strMessage(5)
End With

Else
fAutoMode = False
fSMSMode = False
With objMsgBox
.FontStyle "Notice", vbRed, FONT_STYLE_BOLD
.Notice = strMessage(6)
End With
End If

With objMsgBox
.NoticeEnable = True
.ButtonLabel(CloseButton) = strMessage(13)
.ButtonEnable(CloseButton) = True
If exitCode = 0 Then .ButtonSetFocus CloseButton
If (exitCode <> 0) Or (Not fSMSMode) Or (Not fAutoMode) Then .Sleep 0, True
.Close
End With
End If

Set objMsgBox = Nothing
Set objHelper = Nothing

objWshShell.CurrentDirectory = curFolder

'----------------------------------------------------------------------'
' Clean '
'----------------------------------------------------------------------'

If fDoClean Then

If debugMode Then
With objFS.GetFolder(myFolder)
PopupMsg "Clean:" & vbCrLf & _
" Folder.Name = " & .Name & vbCrLf & _
" Folder.Files.Count = " & .Files.Count & vbCrLf & _
" Folder.SubFolders.Count = " & .SubFolders.Count
End With
End If

retryCount = 10
Do
WScript.Sleep 500
On Error Resume Next
objFS.DeleteFolder myFolder, True
On Error Goto 0
If Not objFS.FolderExists(myFolder) Then
If debugMode Then PopupMsg "Clean: Succeeded."
Exit Do
Else
retryCount = retryCount - 1
If debugMode And (retryCount > 0) Then PopupWernMsg "Clean: Retry!"
End If
Loop While retryCount > 0
If retryCount = 0 Then
PopupWernMsg "Could not delete """ & myFolder & """ folder!" & vbCrLf & _
"Please delete it by yourself."
exitCode = 2
End If

End If

WScript.Quit(exitCode)

'----------------------------------------------------------------------'
' Check FW '
'----------------------------------------------------------------------'

Function CheckFW(ByVal strFW, ByVal strParam1)
Dim exeParam, exeParam1, flgMsgBox, aryFW

exeParam1 = ""
addParam exeParam1, InfoExe, False
exeParam1 = exeParam1 & " " & strParam1

flgMsgBox = objHelper.IsPopup(objMsgBox)

exeParam = exeParam1
addParam exeParam, strFW, False
If debugMode Then PopupMsg "CheckFW: exeParam 1 = [" & exeParam & "]"

With objHelper.CreateProcess
.Exec exeParam, False
Do While .Status = 0
If flgMsgBox Then
objMsgBox.Sleep 100
Else
WScript.Sleep 100
End If
Loop
CheckFW = .ExitCode
End With
If debugMode Then PopupMsg "CheckFW: ExitCode 1 = " & CheckFW
If fDebugMode Then
PopupTitle = "[DEBUG] " & strTitle
PopupMsg exeParam & vbCrLf & vbCrLf & "-> Exit Code = " & CheckFW
PopupTitle = strTitle
End If
End Function

'----------------------------------------------------------------------'
' String Replace '
'----------------------------------------------------------------------'

Function StringReplace(ByVal str, ByVal patrn, ByVal replStr)
Dim reg
Set reg = New RegExp
With reg
.Pattern = patrn
.Global = True
.IgnoreCase = False
.MultiLine = True
StringReplace = .Replace(str, replStr)
End With
Set reg = Nothing
End Function

'----------------------------------------------------------------------'
' Translate Messages '
'----------------------------------------------------------------------'

Sub TranslateMessages
Dim reg, file, str, num, msg, oMatch
Set reg = New RegExp
With objFS
file = .BuildPath(myFolder, .GetBaseName(myName) & "." & LangID)
If Not .FileExists(file) then file = .BuildPath(myFolder, .GetBaseName(myName) & "." & strDefLangId)
If .FileExists(file) then
With .OpenTextFile(file)
Do Until .AtEndOfStream
str = .ReadLine
num = 0
msg = ""
With reg
.Pattern = "^(\d+)=(.*)$"
.IgnoreCase = False
For Each oMatch in .Execute(str)
With oMatch
num = CInt(.SubMatches(0))
msg = .SubMatches(1)
End With
Next
End With
If (num >= LBound(strMessage)) And (num <= UBound(strMessage)) And (msg <> "") Then
msg = StringReplace(msg, "\\n", vbCrLf)
msg = StringReplace(msg, "\\t", vbTab)
strMessage(num) = msg
End If
Loop
End With
End If
End With
Set reg = Nothing
End Sub

'----------------------------------------------------------------------'
' Popup Messages '
'----------------------------------------------------------------------'

Sub PopupMsg(msg)
objWshShell.Popup msg, 0, PopupTitle, vbOkOnly Or vbApplicationModal
End Sub

Sub PopupTimeMsg(msg, timeout)
objWshShell.Popup msg, timeout, PopupTitle, vbOkOnly Or vbApplicationModal
End Sub

Sub PopupInfoMsg(msg)
objWshShell.Popup msg, 0, PopupTitle, vbOkOnly Or vbInformation Or vbApplicationModal
End Sub

Sub PopupWernMsg(msg)
objWshShell.Popup msg, 0, PopupTitle, vbOkOnly Or vbExclamation Or vbApplicationModal
End Sub

Sub PopupErrMsg(msg)
objWshShell.Popup msg, 0, PopupTitle, vbOkOnly Or vbCritical Or vbApplicationModal
End Sub

'----------------------------------------------------------------------'
' Get OS Type '
'----------------------------------------------------------------------'

Function GetOStype
GetOStype = "Unknown"
On Error Resume Next
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
For Each objSys in objWMI.ExecQuery("Select * from Win32_OperatingSystem")
With objSys
Select Case .OStype
Case 16 'Windows 95
GetOStype = "Win95"
Case 17 'Windows 98
GetOStype = "Win98"
Case 18
Select Case Left(.Version, 3)
Case "4.0"
GetOStype = "WinNT4" 'Windows NT 4.0
Case "5.0"
GetOStype = "Win2000" 'Windows 2000
Case "5.1"
GetOStype = "WinXP" 'Windows XP
Case "5.2"
GetOStype = "WinSvr2003" 'Windows Server 2003
Case "6.0"
GetOStype = "WinVista" 'Windows Vista
Case "6.1"
GetOStype = "Win7" 'Windows 7
Case Else
GetOStype = "WinNTbase" 'Unknown (Windows NT Base)
End Select
Case Else
GetOStype = "Unknown" 'Unknown
End Select
End With
Next
On Error Goto 0
Set objWMI = Nothing
End Function

'----------------------------------------------------------------------'
' CTosWshHelper Class '
'----------------------------------------------------------------------'

Const CTWH_MutexName = "ME-FW_Updater"
Const CTWH_ServerName = "TosWshHelper"
Const CTWH_ServerExt = ".exe"
Const CTWH_IMutex = "Mutex"
Const CTWH_IPopup = "Popup"
Const CTWH_IMachine = "Machine"
Const CTWH_IProcess = "Process"

Const POPUP_BUTTON1 = 1
Const POPUP_BUTTON2 = 2
Const POPUP_BUTTON3 = 3

Const FONT_STYLE_NONE = &H00
Const FONT_STYLE_BOLD = &H01
Const FONT_STYLE_ITALIC = &H02
Const FONT_STYLE_UNDERLINE = &H04
Const FONT_STYLE_STRIKEOUT = &H08
Const FONT_STYLE_BLINK = &H80

Class CTosWshHelper

Private Server, bComFound, bComActivated
Private objMutex, objMachine

Private Sub Class_Initialize
Server = ""
bComFound = False
bComActivated = False
On Error Resume Next
Set objMutex = WScript.CreateObject(CTWH_ServerName & "." & CTWH_IMutex)
If Err.Number = 0 Then bComFound = True
On Error Goto 0
If Not bComFound Then
Server = objFS.BuildPath(objFS.GetParentFolderName(WScript.ScriptFullName), CTWH_ServerName & CTWH_ServerExt)
If Not RegServer(Server, True) Then Server = ""
If Server <> "" Then
On Error Resume Next
Set objMutex = WScript.CreateObject(CTWH_ServerName & "." & CTWH_IMutex)
If Err.Number = 0 Then bComFound = True
On Error Goto 0
End If
End If
If bComFound Then
On Error Resume Next
bComActivated = objMutex.Create(CTWH_MutexName)
On Error Goto 0
If bComActivated Then
On Error Resume Next
Set objMachine = WScript.CreateObject(CTWH_ServerName & "." & CTWH_IMachine)
If Err Then Set objMachine = Nothing
On Error Goto 0
End If
End If
End Sub

Private Sub Class_Terminate
Dim n
On Error Resume Next
If bComFound Then
Set objMachine = Nothing
objMutex.Close
Set objMutex = Nothing
End If
RegServer Server, False
On Error Goto 0
End Sub

Public Property Get Activated
Activated = bComActivated
End Property

Public Function IsPopup(objPopup)
IsPopup = (TypeName(objPopup) = CTWH_IPopup)
End Function

Public Function CreatePopup
Set CreatePopup = Nothing
On Error Resume Next
Set CreatePopup = WScript.CreateObject(CTWH_ServerName & "." & CTWH_IPopup)
On Error Goto 0
If Not IsPopup(CreatePopup) Then Set CreatePopup = Nothing
End Function

Public Function IsMachine(objMachine)
IsMachine = (TypeName(objMachine) = CTWH_IMachine)
End Function

Public Function MachineInfo(ByVal Name)
MachineInfo = ""
If bComFound And IsMachine(objMachine) Then
On Error Resume Next
With objMachine
MachineInfo = .Info(Name)
End With
On Error Goto 0
End If
End Function

Public Function PowerCheck
Dim ACLineStatus, BatteryLifePercent
ACLineStatus = MachineInfo("ACLineStatus")
BatteryLifePercent = MachineInfo("BatteryLifePercent")
If BatteryLifePercent = "Unknown" Then BatteryLifePercent = 0
PowerCheck = (ACLineStatus = "Online") And (BatteryLifePercent > 10)
End Function

Public Function IsProcess(objProcess)
IsProcess = (TypeName(objProcess) = CTWH_IProcess)
End Function

Public Function CreateProcess
Set CreateProcess = Nothing
On Error Resume Next
Set CreateProcess = WScript.CreateObject(CTWH_ServerName & "." & CTWH_IProcess)
On Error Goto 0
If IsProcess(CreateProcess) Then
CreateProcess.CurrentDirectory = myFolder
Else
Set CreateProcess = Nothing
End If
End Function

End Class

'----------------------------------------------------------------------'
' Register Server '
'----------------------------------------------------------------------'

Function RegServer(ByVal Server, ByVal fRegister)
Dim Regsvr, exeParam
RegServer = False
If Server <> "" then
With objFS
exeParam = ""
If LCase(.GetExtensionName(Server)) = "exe" Then
If .FileExists(Server) then
addParam exeParam, Server, False
If fRegister Then
addParam exeParam, "/regserver", False
Else
addParam exeParam, "/unregserver", False
End If
End If
ElseIf LCase(.GetExtensionName(Server)) = "dll" Then
Regsvr = .BuildPath(.GetSpecialFolder(1).Path, "regsvr32.exe")
If .FileExists(Regsvr) And .FileExists(Server) then
exeParam = ""
addParam exeParam, Regsvr, False
addParam exeParam, "/s", False
If Not fRegister Then addParam exeParam, "/u", False
addParam exeParam, Server, False
End If
End If
End With
If exeParam <> "" Then
On Error Resume Next
With objWshShell.Exec(exeParam)
Do While .Status = 0
WScript.Sleep 50
Loop
RegServer = (.ExitCode = 0)
End With
On Error Goto 0
End If
End If
End Function

'----------------------------------------------------------------------'
' Power On Button Click '
'----------------------------------------------------------------------'

Function OnButtonClick(ByVal Click, ByVal Num)
If (Click <> 0) And (Num > 0) Then
OnButtonClick = ((Click And (2 ^ (Num - 1))) <> 0)
Else
OnButtonClick = False
End If
End Function

'----------------------------------------------------------------------'
' Add Param '
'----------------------------------------------------------------------'

Sub addParam(param, ByVal str, ByVal unshift)
If str <> "" Then
If InStr(str, " ") >= 1 Then str = """" & str & """"
If unshift Then
If param <> "" Then param = " " & param
param = str & param
Else
If param <> "" Then param = param & " "
param = param & str
End If
End If
End Sub

'----------------------------------------------------------------------'
' CIniFile Class '
'----------------------------------------------------------------------'

Class CIniFile

Private objIni

' Initialize '
Private Sub Class_Initialize
Set objIni = WScript.CreateObject("Scripting.Dictionary")
End Sub

' Terminate '
Private Sub Class_Terminate
Set objIni = Nothing
End Sub

' Open '
Public Function Open(ByVal strIniPath)
Dim bRes, objIniFile, strTmp, strSection, strKey, strVal
Const defSection = "default"
bRes = False
On Error Resume Next
objIni.RemoveAll
With objFS
If .FileExists(strIniPath) then
Set objIniFile = .OpenTextFile(strIniPath)
bRes = (Err.Number = 0)
End If
End With
If bRes then
strSection = defSection
With objIniFile
Do Until .AtEndOfStream
strTmp = Trim(Replace(Replace(.ReadLine, vbCrLf, ""), vbTab, " "))
If Left(strTmp, 1) = ";" Then strTmp = ""
If strTmp <> "" Then
If (Left(strTmp, 1) = "[") And (Right(strTmp, 1) = "]") Then
If Len(strTmp) > 2 Then
strSection = LCase(Mid(strTmp, 2, Len(strTmp) - 2))
Else
strSection = defSection
End If
With objIni
If Not .Exists(strSection) Then .Add strSection, 1
End With
ElseIf InStr(strTmp, "=") > 1 Then
strKey = strSection & ";" & LCase(Trim(Split(strTmp, "=", 2)(0)))
strVal = Trim(Split(strTmp, "=", 2)(1))
If (Left(strVal, 1) = """") And (Right(strVal, 1) = """") Then
If Len(strVal) > 2 Then
strVal = LCase(Mid(strVal, 2, Len(strVal) - 2))
Else
strVal = ""
End If
End If
With objIni
If .Exists(strKey) Then
.Key(strKey) = strVal
Else
.Add strKey, strVal
End If
End With
End If
End If
Loop
.Close
End With
Set objIniFile = Nothing
End If
On Error Goto 0
Open = bRes
End Function

' Close '
Public Sub Close
On Error Resume Next
objIni.RemoveAll
On Error Goto 0
End Sub

' Section Exists '
Public Function SectionExists(ByVal strSection)
SectionExists = False
On Error Resume Next
If strSection <> "" Then
If objIni.Exists(LCase(strSection)) Then SectionExists = True
End If
On Error Goto 0
End Function

' Value Exists '
Public Function ValueExists(ByVal strSection, ByVal strKey)
Dim strSectKey
ValueExists = False
On Error Resume Next
If (strSection <> "") And (strKey <> "") Then
strSectKey = LCase(strSection & ";" & strKey)
If objIni.Exists(strSectKey) Then ValueExists = True
End If
On Error Goto 0
End Function

' Read Value '
Public Function ReadValue(ByVal strSection, ByVal strKey)
Dim strSectKey
ReadValue = ""
On Error Resume Next
If (strSection <> "") And (strKey <> "") Then
strSectKey = LCase(strSection & ";" & strKey)
With objIni
If .Exists(strSectKey) Then ReadValue = .Item(strSectKey)
End With
End If
On Error Goto 0
End Function

' Read Bool'
Public Function ReadBool(ByVal strSection, ByVal strKey)
Dim strSectKey, strVal
ReadBool = False
On Error Resume Next
If (strSection <> "") And (strKey <> "") Then
strSectKey = LCase(strSection & ";" & strKey)
With objIni
If .Exists(strSectKey) Then
strVal = LCase(.Item(strSectKey))
ReadBool = ((strVal = "1") Or (strVal = "true"))
End If
End With
End If
On Error Goto 0
End Function

End Class

Edited by ricktendo64
Link to comment
Share on other sites


It looks like PowerCheck is called in several places, so the easiest way to always pass the check might be this:


Public Function PowerCheck
PowerCheck = True
End Function

The better solution would be to hook up an AC adapter or recharge the battery. If power fails while you are updating firmware, that component (or the whole system) could be hosed permanently. The power check is there for a very good reason! :yes:

Edited by jumper
Link to comment
Share on other sites

The better solution would be to hook up an AC adapter or recharge the battery. If power fails while you are updating firmware, that component (or the whole system) could be hosed permanently. The power check is there for a very good reason! :yes:

Cant, its a AIO desktop (which normally use a laptop motherboard) and it has no battery

Thanks for the help, will report back tomorrow if it works

BTW can you look at the /force switch for me, see if that will skip the PowerCheck or what it forces

Link to comment
Share on other sites

BTW can you look at the /force switch for me, see if that will skip the PowerCheck or what it forces

At first glance (a very quick glance) it would. But I don't see why you'd even bother with this script. All it does is run preliminary checks and you want to bypass them. Why not just run the updater directly then?

FWUpdLcl.exe -F ME171176.BIN

or

FWUpdLcl.exe -F ME171176.BIN -FORCERESET

Link to comment
Share on other sites

Because there were two commands and I was not sure which to use...Thanks, if the first fails I will try your solution

When you run it, it says one of the options is:

-FORCERESET Automatically Reboots system after update (if needed).

That's the only difference.

Link to comment
Share on other sites

No, there is actually two separate bios (.BIN) files, the .VBE chooses the correct one

UpdtExeParamAM=-F ME571176.BIN
UpdtExeParamNA=-F ME171176.BIN
UpdtExeParamAMR=-F ME571176.BIN -FORCERESET
UpdtExeParamNAR=-F ME171176.BIN -FORCERESET

Edited by ricktendo64
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...