Bastle grade an einer Funktion seit ein paar Tagen.
Seit heute (ohne einen für mich ersichtlichen Grund) bricht diese jedesmal ab mit der im weiteren genannten Fehlermeldung, wobei das Skript zuvor immer durchgelaufen ist.
Einziger Unterschied: Ich habe die Funktion in eine eigene Bibliotheksdatei kopiert, da die Funktion langsam zu groß geworden ist.
(95) [7] [Aug 29 14:21:46:209] [opsifunctest] Found ImportLib statement for file: p:\opsifunctest\..\lib\myOpsiLibrary\fs_adv.opsiscript and function: _doStd64
(96) [5] [Aug 29 14:21:46:251] [opsifunctest] Imported function : _doStd64 from file: p:\lib\myOpsiLibrary\fs_adv.opsiscript
(97) [2] [Aug 29 14:21:46:254] [opsifunctest] Found DefFunc without EndFunc
(98) [2] [Aug 29 14:21:46:254] [opsifunctest] Syntax Error in Section: Actions (Command in line 179 in section: Actions; file: testlib_aufruf.opsiscript; section start at line: 1; origin: testlib_aufruf.opsiscript; line: 179): -> Found DefFunc without EndFunc
Anbei der Code:
Code: Alles auswählen
DefFunc _doStd64(val $relPTI$ : string, val $MinimumSpace$ : string) : void
DefStringList $ProductMap_List$
DefVar $ProductId$
DefVar $ProductName$
DefVar $ProductVersion$
DefVar $ActionRequest$
Set $ProductMap_List$ = getProductMap
Set $ProductId$ = getValue("id", $ProductMap_List$)
Set $ProductName$ = getValue("name", $ProductMap_List$)
Set $ProductVersion$ = getValue("productversion", $ProductMap_List$)
Set $ActionRequest$ = getValue("actionrequest", $ProductMap_List$)
comment "Search for product picture"
if (FileExists("%ScriptPath%\..\lib\icons\%installingProdName%.png"))
comment "logo at local library/icons found."
ShowBitmap "%ScriptPath%\..\lib\icons\%installingProdName%.png" $ProductName$
else
comment "no logo at local library/icons, searching in ScriptPath ..."
if (FileExists("%ScriptPath%\%installingProdName%.png"))
comment "logo at %Scriptpath% found."
ShowBitmap "%ScriptPath%\%installingProdName%.png" $ProductName$
else
comment "no logo was found. Proceeding without any logo."
endif
endif
if($ActionRequest$ = "setup")
Comment "Setup was called."
Message "Installing " + $ProductId$
DefVar $PTR$
if (not(FileExistsSysNative("%ScriptPath%\" + $relPTI$)) OR (DirectoryExists("%ScriptPath%\" + $relPTI$)))
Comment "Installer-runnable not found, trying to guess..."
DefVar $pspolicysafe$
DefStringList $runnablesList$
DefStringList $installerKeywords$
DefVar $counter$
DefStringList $searchResults$
DefStringList $tempSectionOutput$
Set $pspolicysafe$ = takeString(0,shellCall('powershell.exe get-executionpolicy'))
Set $installerKeywords$ = createStringList('setup','inst','64','win','amd')
shellCall('powershell.exe set-executionpolicy Unrestricted')
Set $runnablesList$ = getSubListByContaining("Microsoft.PowerShell.Core\FileSystem", getOutStreamFromSection("ExecWith_PS_searchForRunnables powershell.exe winst /SysNative"))
if (count($runnablesList$) INT> "0")
if (count($runnablesList$) INT= "1")
Comment "A sole runnable (exe, msi or bin) was found in scriptpath or its respective childs."
Comment "Try to check name for typical installer keywords."
Set $PTR$ = takeString(1,splitString(takeString(0,$runnablesList$), "::"))
Set $counter$ = "0"
for $item$ in $installerKeywords$ do Sub_checkForInstKeywords
Comment "Verifying..."
if (($counter$ INT> "0") AND not(contains(lower($PTR$), "uninst")) AND not(contains(lower($PTR$), "deinst")))
Comment $PTR$ + " seems to be an installer. Will take it and hope this does not end bad."
else
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
LogError "Could not verify runnable as an possible installer."
isFatalError
endif
else
Comment "There are several runnables (exe, msi or bin) in scriptpath or its respective childs. Try to guess further."
DefStringList $hasKeyword$
DefVar $loopHelperVar$
for %i% = "0" to calculate(count($runnablesList$)+"-1") do Set $runnablesList$ = setStringInListAtIndex(takeString(1,splitString(takeString(%i%,$runnablesList$),"::")),$runnablesList$,"%i%")
for %n% = "0" to calculate(count($runnablesList$)+"-1") do Sub_checkForInstKeywordsInList
if not(count($runnablesList$) INT= count($hasKeyword$))
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
LogError "Fatal Error in Function _doStd64. Aborting operation."
isFatalError
endif
Set $counter$ = "0"
for %u% = "0" to calculate(count($runnablesList$)+"-1") do Sub_countPossibInst
if ($counter$ INT= "0")
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
LogError "Fatal Error in Function _doStd64. Aborting operation."
isFatalError
else
if not($counter$ INT= "1")
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
LogError "There are more than one runnable (exe, msi or bin) in scriptpath or its respective childs, which could be potential installer files. Give relative path to installer with parameter to this function."
isFatalError
else
Comment "Only a single runnable (exe, msi or bin) was found in scriptpath or its respective childs, which could be a potential installer file."
for %x% = "0" to calculate(count($runnablesList$)+"-1") do Sub_getRunByMap
Comment $PTR$ + " seems to be an installer. Will take it and hope this does not end bad."
endif
endif
endif
else
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
LogError "No runnable (exe, msi or bin) installer was found in scriptpath or its respective childs."
isFatalError
endif
else
Set $PTR$ = "%ScriptPath%\" + $relPTI$
endif
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
Comment $PTR$
if not (isRegexMatch($MinimumSpace$, "^[1-9][0-9]* MB$"))
DefStringList $estMinSpcList$
Comment "Invalid input for parameter MinimumSpace. Only input with matches regex pattern ^[1-9][0-9]* MB$ is allowed. Trying to estimate the required space on C: conservatively."
shellCall('powershell.exe set-executionpolicy Unrestricted')
Set $estMinSpcList$ = getSubListByContaining("Bytes", shellCall('powershell.exe robocopy "%ScriptPath%" "c:\tmp" /zb /e /l /r:1 /w:1 /nfl /ndl /nc /fp /bytes /np /njh'))
shellCall('powershell.exe set-executionpolicy ' + $pspolicysafe$)
if not(count($estMinSpcList$) INT= "1")
LogError "Fatal Error in Function _doStd64. Aborting operation."
isFatalError
endif
Set $MinimumSpace$ = takeString(2,splitStringOnWhiteSpace(takeString(0,$estMinSpcList$)))
if not(isNumber($MinimumSpace$))
LogError "Fatal Error in Function _doStd64. Aborting operation."
isFatalError
endif
if ($MinimumSpace$ INT< "100000")
LogError "Estimated minimum space too small to make sense. Aborting Operation."
isFatalError
endif
endif
if not (GetMsVersionInfo = "10.0")
LogError "Sorry, this installation package is only for Windows 10."
isFatalError
endif
if not (GetSystemType = "64 Bit System")
LogError "Sorry, this installation package is only for 64bit systems."
isFatalError
endif
if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
LogError "Not enough space on %SystemDrive%, at least " + $MinimumSpace$ + " on drive %SystemDrive% is needed."
isFatalError
endif
else
if($ActionRequest$ = "uninstall")
;do uninstall routines
else
LogError "Only action requests <setup> and <uninstall> are allowed. Aborting Operation."
isFatalError
endif
endif
[ExecWith_PS_searchForRunnables]
Get-ChildItem -Path '%ScriptPath%' -Recurse -force -ErrorAction SilentlyContinue | Where-Object {($_.Name -like '*.exe') -or ($_.Name -like '*.msi') -or ($_.Name -like '*.bin')} | Select-Object PSPath
[Sub_checkForInstKeywords]
if contains(lower($PTR$),"$item$")
Set $counter$ = calculate($counter$+"1")
endif
[Sub_checkForInstKeywordsInList]
Set $loopHelperVar$ = "%n%"
Set $counter$ = "0"
for %t% = "0" to calculate(count($installerKeywords$)+"-1") do Sub_Sub_checkForInstKeywordsInList
if (($counter$ INT> "0") AND not(contains(lower(takeString($loopHelperVar$,$runnablesList$)), "uninst")) AND not(contains(lower(takeString($loopHelperVar$,$runnablesList$)), "deinst")))
Set $hasKeyword$ = addtolist($hasKeyword$, "true")
else
Set $hasKeyword$ = addtolist($hasKeyword$, "false")
endif
[Sub_Sub_checkForInstKeywordsInList]
if ((contains(lower(takeString($loopHelperVar$,$runnablesList$)),takeString(%t%,$installerKeywords$))))
Set $counter$ = calculate($counter$+"1")
endif
[Sub_countPossibInst]
if (stringToBool(takeString(%u%, $hasKeyword$)))
Set $counter$ = calculate($counter$+"1")
endif
[Sub_getRunByMap]
if (stringToBool(takeString(%x%, $hasKeyword$)))
Set $PTR$ = takeString(%x%, $runnablesList$)
endif
[ExecWith_PS_estMinSpc]
robocopy "%ScriptPath%" "c:\tmp" /zb /e /l /r:1 /w:1 /nfl /ndl /nc /fp /bytes /np /njh
endfunc