Archived
1
0

x fixed bug in mb_EnvTools.ahk with not using EnvVars where the name was less than 2 characters (instead of not using EnvVars where the VALUE is less than 2 chars)

+ implemented multi-commands on all 4 events (hostConfigure, appStart, appStop, hostCleanUp)
x hostCleanUp-CopyDataFiles showed ERR instead of SKP
* grouped translation errors instead of displaying one MsgBox per error
+ added trying to delete single registry value if key is not found
This commit is contained in:
mbirth 2007-05-29 12:16:39 +00:00
parent 80851ff25a
commit 9f143344e0
7 changed files with 102 additions and 35 deletions

View File

@ -30,6 +30,14 @@ IfNotExist %U3_APP_DATA_PATH%\%LSn%\%LADn%
} }
SetWorkingDir %U3_HOST_EXEC_PATH% SetWorkingDir %U3_HOST_EXEC_PATH%
Loop %runsta0%
{
CurCmd := runsta%A_Index%
CurCmd := EnvParseStr(CurCmd)
RunWait %CurCmd%
}
cmdl := AppExe cmdl := AppExe
Loop %0% Loop %0%
{ {

View File

@ -1,7 +1,7 @@
ASOnExit: ASOnExit:
StepsAll = 1 StepsAll = 1
If (StrLen(RunBeforeStop) > 0) If runstp0 > 0
StepsAll++ StepsAll++
StepsStep := 100/StepsAll StepsStep := 100/StepsAll
StepsPos = 0 StepsPos = 0
@ -9,13 +9,15 @@ StepsPos = 0
Progress b2 x%PL% y%PT% w%PW% m FM%PFM% FS%PFS%, U3Helper %U3HVer% - (c)2006-2007 Markus Birth <mbirth@webwriters.de>, Stopping %AppName% ..., AHKProgress-%AppName% Progress b2 x%PL% y%PT% w%PW% m FM%PFM% FS%PFS%, U3Helper %U3HVer% - (c)2006-2007 Markus Birth <mbirth@webwriters.de>, Stopping %AppName% ..., AHKProgress-%AppName%
WinSet Transparent, %PTrans%, AHKProgress-%AppName% WinSet Transparent, %PTrans%, AHKProgress-%AppName%
If (StrLen(RunBeforeStop) > 0) Loop %runstp0%
{ {
Progress % StepsPos*StepsStep, Running stop command ... CurCmd := runstp%A_Index%
RunBeforeStop := EnvParseStr(RunBeforeStop) Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/runstp0, Running stop command ... %CurCmd%
RunWait %RunBeforeStop% CurCmd := EnvParseStr(CurCmd)
StepsPos++ RunWait %CurCmd%
} }
If runstp0 > 0
StepsPos++
SplitPath AppExe, AppFile, null, null, null, null SplitPath AppExe, AppFile, null, null, null, null

View File

@ -5,7 +5,7 @@
; ########################################################################## ; ##########################################################################
StepsAll = 0 StepsAll = 0
If (StrLen(RunBeforeEject) > 0) If runeje0 > 0
StepsAll++ StepsAll++
If regsvr0 > 0 If regsvr0 > 0
StepsAll++ StepsAll++
@ -27,13 +27,15 @@ StepsPos = 0
Progress b2 x%PL% y%PT% w%PW% m FM%PFM% FS%PFS%, U3Helper %U3HVer% - (c)2006-2007 Markus Birth <mbirth@webwriters.de>, Cleaning up %AppName% ..., AHKProgress-%AppName% Progress b2 x%PL% y%PT% w%PW% m FM%PFM% FS%PFS%, U3Helper %U3HVer% - (c)2006-2007 Markus Birth <mbirth@webwriters.de>, Cleaning up %AppName% ..., AHKProgress-%AppName%
WinSet Transparent, %PTrans%, AHKProgress-%AppName% WinSet Transparent, %PTrans%, AHKProgress-%AppName%
If (StrLen(RunBeforeEject) > 0) Loop %runeje0%
{ {
Progress % StepsPos*StepsStep, Running shutdown command ... CurCmd := runeje%A_Index%
RunBeforeEject := EnvParseStr(RunBeforeEject) Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/runeje0, Running shutdown command ... %CurCmd%
RunWait %RunBeforeEject% CurCmd := EnvParseStr(CurCmd)
StepsPos++ RunWait %CurCmd%
} }
If runeje0 > 0
StepsPos++
If (U3_IS_DEVICE_AVAILABLE <> "true") If (U3_IS_DEVICE_AVAILABLE <> "true")
{ {
@ -100,7 +102,6 @@ Else
Skipped = 0 Skipped = 0
Errors = 0 Errors = 0
Dirs = 0 Dirs = 0
CopyErrors := ""
FileGetAttrib FAttr, %CurMask% FileGetAttrib FAttr, %CurMask%
IfInString FAttr, D IfInString FAttr, D
@ -119,13 +120,13 @@ Else
IfInString FAttr, D IfInString FAttr, D
{ {
; also create empty directories ; also create empty directories
Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/FileCount))/datexe0, Creating directory %CurFile% ... (CPY:%Copied% / DIR:%Dirs% / ERR:%Errors%) Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/FileCount))/datexe0, Creating directory %CurFile% ... (CPY:%Copied% / DIR:%Dirs% / SKP:%Skipped% / ERR:%Errors%)
FileCreateDir %TargFile% FileCreateDir %TargFile%
Dirs++ Dirs++
} }
Else Else
{ {
Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/FileCount))/datexe0, Copying data %CurFile% ... (CPY:%Copied% / DIR:%Dirs% / ERR:%Errors%) Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/FileCount))/datexe0, Copying data %CurFile% ... (CPY:%Copied% / DIR:%Dirs% / SKP:%Skipped% / ERR:%Errors%)
FileCopyNewer(CurFile, TargFile) FileCopyNewer(CurFile, TargFile)
If ErrorLevel = 2 If ErrorLevel = 2
{ {
@ -217,16 +218,23 @@ Else
;Translate paths in text files ;Translate paths in text files
SetWorkingDir %U3_APP_DATA_PATH% SetWorkingDir %U3_APP_DATA_PATH%
TransErrors := ""
Loop %dattxt0% Loop %dattxt0%
{ {
Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/dattxt0, Translating paths in file %CurFile% ... OutIndex = %A_Index%
CurMask := dattxt%A_Index% CurMask := dattxt%A_Index%
Loop %CurMask%
FileCount = 0
Loop %CurMask%, 0, 0
{
FileCount++
}
Loop %CurMask%, 0, 0
{ {
CurFile := A_LoopFileFullPath CurFile := A_LoopFileFullPath
TmpFile := A_LoopFileDir . "\$$$" . A_LoopFileName TmpFile := A_LoopFileDir . "\$$$" . A_LoopFileName
FileMove %U3_APP_DATA_PATH%\%CurFile%, %U3_APP_DATA_PATH%\%TmpFile%, 1 FileMove %U3_APP_DATA_PATH%\%CurFile%, %U3_APP_DATA_PATH%\%TmpFile%, 1
Progress % StepsPos*StepsStep+StepsStep*(A_Index-0.5)/dattxt0, Translating paths in file %CurFile% ... Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/FileCount))/dattxt0, Translating paths in file %CurFile% ...
Loop Read, %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile% Loop Read, %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile%
{ {
IfNotInString A_LoopReadLine, \ IfNotInString A_LoopReadLine, \
@ -244,12 +252,15 @@ Else
Else Else
{ {
FileMove %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile% FileMove %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile%
MsgBox 4112, Error while translating, The datafile %CurFile% could not be translated. The original state has been restored (hopefully). TransErrors .= "File: " . CurFile . " (Error while translating)`n"
} }
} }
} }
SetWorkingDir %A_ScriptDir% SetWorkingDir %A_ScriptDir%
If (TransErrors <> "")
MsgBox 4112, Error while translating, Following files could not be translated:`n`n%TransErrors%`n`nThe original state has been restored (hopefully).
If dattxt0 > 0 If dattxt0 > 0
StepsPos++ StepsPos++
} }
@ -309,6 +320,11 @@ If (KeepSettings = "0" or Unattended = "1")
CurBranch := regdel%A_Index% CurBranch := regdel%A_Index%
SplitFirst(RegRoot, RegSub, CurBranch, "\") SplitFirst(RegRoot, RegSub, CurBranch, "\")
RegDelete %RegRoot%, %RegSub% RegDelete %RegRoot%, %RegSub%
If ErrorLevel
{
SplitLast(RegSub, RegKey, RegSub, "\")
RegDelete %RegRoot%, %RegSub%, %RegKey%
}
} }
If regdel0 > 0 If regdel0 > 0

View File

@ -7,6 +7,8 @@
StepsAll = 0 StepsAll = 0
IfNotExist %U3_HOST_EXEC_PATH%\%A_ScriptName% IfNotExist %U3_HOST_EXEC_PATH%\%A_ScriptName%
StepsAll++ StepsAll++
If runcon0 > 0
StepsAll++
If regsvr0 > 0 If regsvr0 > 0
StepsAll++ StepsAll++
If dattxt0 > 0 If dattxt0 > 0
@ -23,16 +25,25 @@ StepsPos = 0
Progress b2 x%PL% y%PT% w%PW% m FM%PFM% FS%PFS%, U3Helper %U3HVer% - (c)2006-2007 Markus Birth <mbirth@webwriters.de>, Preparing %AppName% ..., AHKProgress-%AppName% Progress b2 x%PL% y%PT% w%PW% m FM%PFM% FS%PFS%, U3Helper %U3HVer% - (c)2006-2007 Markus Birth <mbirth@webwriters.de>, Preparing %AppName% ..., AHKProgress-%AppName%
WinSet Transparent, %PTrans%, AHKProgress-%AppName% WinSet Transparent, %PTrans%, AHKProgress-%AppName%
; made following step not to display b/c it occurs only once on the first launch of any U3H-app
IfNotExist %U3_HOST_EXEC_PATH%\%A_ScriptName% IfNotExist %U3_HOST_EXEC_PATH%\%A_ScriptName%
{ {
Progress % StepsPos*StepsStep, Copying U3Helper to disk... Progress % StepsPos*StepsStep, Copying U3Helper to disk...
FileCopy %A_ScriptFullPath%, %U3_HOST_EXEC_PATH%\%A_ScriptName%, 0 FileCopy %A_ScriptFullPath%, %U3_HOST_EXEC_PATH%\%A_ScriptName%, 0
StepsPos++ StepsPos++
} }
;****************************************************************************** ;******************************************************************************
Loop %runcon0%
{
CurCmd := runcon%A_Index%
Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/runcon0, Running config command ... %CurCmd%
CurCmd := EnvParseStr(CurCmd)
RunWait %CurCmd%
}
If runcon0 > 0
StepsPos++
Progress % StepsPos*StepsStep, Checking registry settings... Progress % StepsPos*StepsStep, Checking registry settings...
keycount = 0 keycount = 0
;Registry stuff ;Registry stuff
@ -112,16 +123,23 @@ If (ForeignSettings = "0")
;Translate paths in text files ;Translate paths in text files
SetWorkingDir %U3_APP_DATA_PATH% SetWorkingDir %U3_APP_DATA_PATH%
TransErrors := ""
Loop %dattxt0% Loop %dattxt0%
{ {
Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/dattxt0, Translating paths in file %CurFile% ... OutIndex = %A_Index%
CurMask := dattxt%A_Index% CurMask := dattxt%A_Index%
Loop %CurMask%
FileCount = 0
Loop %CurMask%, 0, 0
{
FileCount++
}
Loop %CurMask%, 0, 0
{ {
CurFile := A_LoopFileFullPath CurFile := A_LoopFileFullPath
TmpFile := A_LoopFileDir . "\$$$" . A_LoopFileName TmpFile := A_LoopFileDir . "\$$$" . A_LoopFileName
FileMove %U3_APP_DATA_PATH%\%CurFile%, %U3_APP_DATA_PATH%\%TmpFile%, 1 FileMove %U3_APP_DATA_PATH%\%CurFile%, %U3_APP_DATA_PATH%\%TmpFile%, 1
Progress % StepsPos*StepsStep+StepsStep*(A_Index-0.5)/dattxt0, Translating paths in file %CurFile% ... Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/FileCount))/dattxt0, Translating paths in file %CurFile% ...
Loop Read, %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile% Loop Read, %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile%
{ {
IfNotInString A_LoopReadLine, `% IfNotInString A_LoopReadLine, `%
@ -140,12 +158,15 @@ Loop %dattxt0%
Else Else
{ {
FileMove %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile% FileMove %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile%
MsgBox 4112, Error while translating, The datafile %CurFile% could not be translated. The original state has been restored (hopefully). TransErrors .= "File: " . CurFile . " (Error while translating)`n"
} }
} }
} }
SetWorkingDir %A_ScriptDir% SetWorkingDir %A_ScriptDir%
If (TransErrors <> "")
MsgBox 4112, Error while translating, Following files could not be translated:`n`n%TransErrors%`n`nThe original state has been restored (hopefully).
If dattxt0 > 0 If dattxt0 > 0
StepsPos++ StepsPos++

View File

@ -20,15 +20,30 @@ If (StrLen(U3_HOST_EXEC_PATH) > 0)
IniRead AppName, %INIFile%, U3Helper, AppName, unknown IniRead AppName, %INIFile%, U3Helper, AppName, unknown
IniRead AppExe, %INIFile%, U3Helper, AppExe, cmd.exe IniRead AppExe, %INIFile%, U3Helper, AppExe, cmd.exe
IniRead Unattended, %INIFile%, U3Helper, Unattended, 0 IniRead Unattended, %INIFile%, U3Helper, Unattended, 0
IniRead RunBeforeStop, %INIFile%, U3Helper, RunBeforeStop, %A_Space% IniGetKeys("runcon", INIFile, "RunBeforeConfig")
IniRead RunBeforeEject, %INIFile%, U3Helper, RunBeforeEject, %A_Space% IniGetKeys("runsta", INIFile, "RunBeforeStart")
IniGetKeys("runstp", INIFile, "RunBeforeStop")
IniGetKeys("runeje", INIFile, "RunBeforeEject")
IniGetKeys("regsvr", INIFile, "regsvr32") IniGetKeys("regsvr", INIFile, "regsvr32")
IniGetKeys("datexe", INIFile, "DataToExecDir") IniGetKeys("datexe", INIFile, "DataToExecDir")
IniGetKeys("dattxt", INIFile, "ParseFiles") IniGetKeys("dattxt", INIFile, "ParseFiles")
IniGetKeys("dattxt", INIFile, "ParseIniFiles") ; backward compatibility
IniGetKeys("regbak", INIFile, "RegBackup") IniGetKeys("regbak", INIFile, "RegBackup")
IniGetKeys("regdel", INIFile, "RegDelete") IniGetKeys("regdel", INIFile, "RegDelete")
IniGetKeys("fildel", INIFile, "FileDelete") IniGetKeys("fildel", INIFile, "FileDelete")
; backward compatibility:
IniGetKeys("dattxt", INIFile, "ParseIniFiles") ; backward compatibility
IniRead RunBeforeStop, %INIFile%, U3Helper, RunBeforeStop, %A_Space%
IniRead RunBeforeEject, %INIFile%, U3Helper, RunBeforeEject, %A_Space%
If (StrLen(RunBeforeStop) > 0)
{
runstp0++
runstp%runstp0% := RunBeforeStop
}
If (StrLen(RunBeforeEject) > 0)
{
runeje0++
runeje%runeje0% := RunBeforeEject
}
;****************************************************************************** ;******************************************************************************
;** Get Taskbar position ;** Get Taskbar position

View File

@ -2,16 +2,19 @@
AppName=PC OnPoint AppName=PC OnPoint
AppExe=PConPoint.exe AppExe=PConPoint.exe
; enter commandlines to run before stopping the application and before
; ejecting the device. All variables mentioned under [FileDelete] work.
RunBeforeStop=
RunBeforeEject=
; set Unattended to 1 to suppress settings-related questions ; set Unattended to 1 to suppress settings-related questions
; this way, previously existing settings on the host always get ; this way, previously existing settings on the host always get
; replaced by the U3's settings and restored on eject ; replaced by the U3's settings and restored on eject
Unattended=0 Unattended=0
; enter commandlines to run before hostConfigure, appStart (if used via
; U3Helper), stopping the application and before ejecting the device. All
; variables mentioned under [FileDelete] work. One command per line.
[RunBeforeConfig]
[RunBeforeStart]
[RunBeforeStop]
[RunBeforeEject]
[RegBackup] [RegBackup]
; enter registry branches to be backed up (+deleted) on eject ; enter registry branches to be backed up (+deleted) on eject
; and restored on first run ; and restored on first run

View File

@ -45,7 +45,7 @@ EnvSort()
{ {
CurNam := EnvVarsx%A_Index% CurNam := EnvVarsx%A_Index%
CurVal := EnvValsx%A_Index% CurVal := EnvValsx%A_Index%
If ((StrLen(CurVal) > MaxLen) and (StrLen(CurNam) > 1)) If ((StrLen(CurVal) > MaxLen) and (StrLen(CurNam) > 0))
{ {
MaxLen := StrLen(CurVal) MaxLen := StrLen(CurVal)
MaxIndex := A_Index MaxIndex := A_Index
@ -140,6 +140,8 @@ EnvUnparseStr(instring)
{ {
ReplFrom := EnvVals%A_Index% ReplFrom := EnvVals%A_Index%
ReplTo := "%" . EnvVars%A_Index% . "%" ReplTo := "%" . EnvVars%A_Index% . "%"
If (StrLen(ReplFrom) < 2)
Continue
StringReplace instring, instring, %ReplFrom%, %ReplTo%, A StringReplace instring, instring, %ReplFrom%, %ReplTo%, A
} }
return instring return instring