Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;--------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------- #DefineFunction BatchCompile_UDF(sourcedir, recurseflag) ; Selects all Winbatch source files in specified directory ; and compiles them all at once, with no user interaction required ; NOTE: This code will compile all .wbt files using its existing .cmp configuration file or it ; will create a .cmp file using the 'Default' SMALL EXE For Networked PC's compile option. ; ; CAUTION - do not run the compiled version of this program as the script ; will fail to compile itself as the executable will be in use ; instead run just the WBT file, or run the executable from a path that will not be ; processed by this script if rtStatus()== 1 Message("Error","This script cannot be run compiled") exit endif ;Check Recurse Flag flag = 0 if recurseflag == @true then flag = 16 ; scan the drives and find all the winbatch source files AddExtender("wsrch34I.dll") hand=srchInit(sourcedir,"*.WBT","","",flag) temppath = "" while @true file=srchNext(hand) if file=="" then break curdir = FilePath(file) ; ; Ignore the contents of the Recycled Folder if any wbt files are found if StrIndexNc(curdir, "RECYCLED", 1, @FWDSCAN) then continue ; Only process each unique path once if StrICmp(curdir,temppath) == 0 then continue temppath = curdir; set the temppath to prevent reprocessing of this path ;Grab a list of all.wbt files wbtfiles = FileItemize(StrCat(curdir,"*.wbt")) ;skip directories with no .wbt files if wbtfiles == "" then continue count = ItemCount(wbtfiles,@tab) ;Loops once for each .wbt file in this directory For xx = 1 to count ; Create a CMP file file = ItemExtract(xx,wbtfiles,@tab) root = FileRoot(file) cmpfile = StrCat(curdir, root, ".cmp") ;message("The CMP File is",CmpFile) If !FileExist(cmpfile) gosub MakeCmp else ; check to make sure the required settings exist Type = IniReadPvt("Main", "Type", "", cmpfile) Src = IniReadPvt("Main", "Src", "", cmpfile) Targ = IniReadPvt("Main", "Targ", "", cmpfile) ; if any are blank then recreate the CMP file if Type == "" || Src == "" || Targ == "" gosub MakeCmp endif endif Next ; ; Run the compiler with the path name as its only parameter RunShell("C:\Program Files\WinBatch\System\WBCompiler.exe", FileNameShort(curdir), curdir,@normal,@nowait) Wname = "Select projects to compile" If WinWaitExist(Wname, 15) ;ignore keyboard temporarily IgnoreInput(@TRUE) ;Move to the File List Window SendKeysTo(Wname,"+{tab}") ; Select all Files in the Window SendKeysTo(Wname,"^a") ; Now Compile all the files SendKeysTo(Wname,"!o") ;Reenable keyboard IgnoreInput(@FALSE) Wname = "WinBatch Compiler" if WinWaitExist(Wname,15) WinClose(Wname) endif else Display(5,"Compiler Operation Failed to Complete","Program Execution will Continue!") endif endwhile return (@TRUE) :MakeCmp ; MAIN IniWritePvt("Main", "Type", 2, CmpFile) ;SMALL EXE COMPILE OPTION IniWritePvt("Main", "Src", StrCat(CurDir, root, ".wbt"), CmpFile) IniWritePvt("Main", "Targ", StrCat(CurDir, root, ".exe"), CmpFile) IniWritePvt("Main", "Icon", "", CmpFile) IniWritePvt("Main", "CmpVersion", "3", CmpFile) ; Options IniWritePvt("Options", "TechWebPage", "", CmpFile) IniWritePvt("Options", "RunHidden", "0", CmpFile) IniWritePvt("Options", "LargeExtractDest", "0", CmpFile) ; Version Info IniWritePvt("Version Info", "Comments", "", CmpFile) IniWritePvt("Version Info", "CompanyName", "", CmpFile) IniWritePvt("Version Info", "FileDescription", root, CmpFile) IniWritePvt("Version Info", "FileVersion", "1.0", CmpFile) IniWritePvt("Version Info", "InternalName", StrCat(root,".exe"), CmpFile) IniWritePvt("Version Info", "LegalCopyright", "", CmpFile) IniWritePvt("Version Info", "LegalTrademarks", "", CmpFile) IniWritePvt("Version Info", "OriginalFilename", StrCat(root,".exe"), CmpFile) IniWritePvt("Version Info", "ProductName", root, CmpFile) IniWritePvt("Version Info", "ProductVersion", "1.0", CmpFile) ; Other Files IniWritePvt("Other Files", "Count", "0", CmpFile) ; Extenders IniWritePvt("Extenders", "Count", "0", CmpFile) return #EndFunction ;--------------------------------------------------------------------------------------- ;--------------------------------------------------------------------------------------- ; WBT directory to batch compile wbtdir = "C:\WBT_FilesToCompile" BatchCompile_UDF(wbtdir, @false) Message("Batch Compile","Complete!")
Article ID: W16397
File Created: 2008:03:05:11:23:48
Last Updated: 2008:03:05:11:23:48