Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;Winbatch 2007C - Create CAB Files ; ;very simple script, uses current directory files ; ;Stan Littlefield April 32, 2007 ;///////////////////////////////////////////////////////////////// GoSub udfs IntControl(73,1,0,0,0) ;check registry for ocx If ! IsInReg( "MakeCab.MakeCab.1" ) Display("Error...","MakeCab not registered") Exit EndIf cCab = DirScript():"test.cab" If FileExist(cCab) Then FileDelete(cCab) ;this method uses a delimited list ;you can alternately process an array list = FileItemize(DirScript():"*.*") A = AskItemlist("Select Files To Include in .CAB", list, @TAB, @SORTED, @MULTIPLE, @FALSE) BoxOpen("Please Wait.......","Creating:":cCab) n= ItemCount(A,@TAB) oCab = CreateObject( "MakeCab.MakeCab.1" ) lBool = ObjectType("BOOL", 0) ;important to pass this, not @False oCab.CreateCab(cCab,lBool,0,lBool) For i= 1 To n cFile = ItemExtract(i,A,@TAB) oCab.AddFile( DirScript():cFile,cFile ) Next oCab.CloseCab() oCab=0 If FileExist(cCab) BoxText("CAB File Created") TimeDelay(2) EndIf BoxShut() Exit :WBERRORHANDLER oCab=0 ErrorProcessing(1,1,0,0) Exit :CANCEL Exit :udfs #DefineSubRoutine ErrorProcessing(deleteIni,showerr,logfile,Err_Array) If VarType(Err_Array) ==256 WbError = Err_Array[0] wberrorhandlerline = Err_Array[1] wberrorhandleroffset = Err_Array[2] wberrorhandlerassignment = Err_Array[3] wberrorhandlerfile = Err_Array[4] wberrortextstring = Err_Array[5] wberroradditionalinfo = Err_Array[6] wberrorinsegment = Err_Array[7] Else WbError = LastError() EndIf WbTextcode = WbError If WbError==1668||WbError==2669||WbError==3670 ; 1668 ; "Minor user-defined error" ; 2669 ; "Moderate user-defined error" ; 3670 ; "Severe user-defined error" WbError = ItemExtract(1,IntControl(34,-1,0,0,0),":") WbTextcode = -1 EndIf WbErrorString = IntControl(34,WbTextcode,0,0,0) WbErrorDateTime = TimeYmdHms() WbErrorFile = StrCat(DirWindows(0),"WWWBATCH.INI") If deleteIni FileDelete(WbErrorFile) IniWritePvt(WbErrorDateTime,"CurrentScript",WbErrorHandlerFile ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorValue" ,WbError ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorString" ,WbErrorString ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptLine" ,WbErrorHandlerLine ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptOffset" ,WbErrorHandlerOffset ,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarAssignment",WbErrorHandlerAssignment,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarInSegment" ,WbErrorInSegment,WbErrorFile) IniWritePvt("","","",WbErrorFile) EndIf WbErrorMsgText = StrCat(WbErrorDateTime,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Current Script: ",WbErrorHandlerFile,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error# [",WbError,"]",@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error Text: ",wberrortextstring,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"[Extended Information] ",wberroradditionalinfo,@CRLF,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"On Line:",@CRLF,WbErrorHandlerLine,@CRLF) ;WbErrorMsgText = StrCat(WbErrorMsgText,"Offset: ",WbErrorHandlerOffset,@CRLF) If (WbErrorHandlerAssignment>"") Then %WbErrorHandlerAssignment% = "UNKNOWN" WbErrorMsgText = StrCat(WbErrorMsgText,"Assignment/Variable: ",WbErrorHandlerAssignment,@CRLF) If (WbErrorInSegment>"") Then WbErrorMsgText = StrCat(WbErrorMsgText,"In UDF/UDS: ",WbErrorInSegment,@CRLF) If logfile cSep = StrCat(StrFill("=",50),@CRLF) cLogFile = StrCat(DirScript(),"log.err") If ! FileExist(cLogFile) Then FilePut(cLogFile,StrCat("Error Log",@CRLF,cSep)) FilePut(cLogFile,StrCat(FileGet(cLogFile),WbErrorMsgText,cSep)) Display(2,"An Error Occured",StrCat("written to ",cLogFile)) Else If showerr WbErrorMsgText = StrCat(WbErrorMsgText,"[THIS ERROR NOT WRITTEN TO LOG FILE]",@CRLF) Message("An Error Was Encountered",WbErrorMsgText) EndIf EndIf Return(1) #EndSubRoutine #DefineFunction isInReg(cProg) Return( RegExistKey(@REGCLASSES,cProg) ) #EndFunction Return ;///////////////////////////////////////////////////////////////////////////////////////////////////////
Article ID: W18174
Filename: MakeCAB.txt
File Created: 2008:11:25:13:51:08
Last Updated: 2008:11:25:13:51:08