Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

makecab

Status
Not open for further replies.

Jockey4

Programmer
Feb 3, 2017
29
0
0
NL
Hi,

I am working with this legacy project which makes use of cabarc, it seems to be ancient code by Ramani, to create cab files:

Code:
Function gsCabBack
Lparameters lcSource, lcDestination
Local lcCmd, lnSuccess, loShell
If !Empty(m.lcDestination) Or !Empty(m.lcSource)
	lcCmd = "CABARC -r -p N " + ;
		m.lcDestination + Space(1) + m.lcSource
	loShell = Createobject("wscript.shell")
	lnSuccess = m.loShell.Run(m.lcCmd,1,.T.)
	If m.lnSuccess = 0
		=Messagebox("BackUp successful.",0+64,"Backup OK!")
	Else
		=Messagebox("BackUp failed",0+16,"Caution")
	Endif
Endif
Return
This code does not work anymore, since Cabarc is now replace with MakeCab. According to the code should now be:
Code:
lcCmd = "makecab /n "+m.lcSource+ Space(1)+m.lcDestination
However this does not result into making a cab file. Anybody around to point me in the correct direction?

Regards,
Jockey(2)
 
I haven't used cab files since the last millennium, as far as I can remember, instead I always use zip files. I use this free tool:


Note: a quick Google search revealed that Windows ships with a tool called Makecab. Maybe it's easier to use this utility in your case since you will only need to make small adjustments to your code.
 
Don't know makecab, but are spaces in the path of source and/or destination? Then like with any path/filename parameter of a DOS command, these need to be enclosed in quotes.

Besides I bet you need fullpaths, no external process has an idea of the VFP process current working directory.

For makecab to be found you also need to call it with its full path or add it to the Windows System %PATH% (not VFPs SET PATTH).

Bye, Olaf.
 
Olaf,
1) no spaces in the directory
2) the call to makecab works ok, I tested with
Code:
lcCmd = "makecab "C:\temp\E1705log.txt" /n "recording.cab" /L "C:\Archive"]
parameter /L is supposed to make a, if not exsist, directory. After running this routine C:\Archive existed on my pc
Regards,
Jockey2
 
Tore,
I also always use Craig's excellent routine. However in this special case, to modify an existing app, I was requested not to add any other DLL or FLL files (people are a little bit over sensible) so indeed makecab seems to be an excellent alternative, however as explained: I cant get it working!
Would you mind to have a quick look at which I translated into and my VFP procedure:
(tcSource and tcDestination) are filed in directories in C:\ without spaces and tested tcSource tested existing)

Code:
PARAMETERS tcSource, tcDestination
lcCmd = "makecab /n "+m.tcSource+ Space(1)+m.tcDestination
loShell = Createobject("wscript.shell")
lnSuccess = m.loShell.Run(m.lcCmd,1,.T.)
If m.lnSuccess = 0
	=Messagebox("BackUp successful.",0+64,"Backup OK!")
Else
	=Messagebox("BackUp failed",0+16,"Caution")
Endif

Thanks!

Regards,
Jockey(2)
 
Joykey,

well inspect what you get when you do lcCmd = "makecab /n "+m.lcSource+ Space(1)+m.lcDestination with your test call.

You don't have the /L option and parameter.

Bye, Olaf.
 
Olaf,

please check
and you will find:
Code:
Syntax
      MAKECAB [/V[n]] [/D var=value ...] [/L dir] source [destination]
/L dir         Folder location to place destination file (default is current directory).
                  most useful when destination is not specified.

Regards,

Jockey2
 
Olaf,

I had runned (also) with the optional /L parameter it worked, the directory was created, however there was no cab file created.
Regards,
Jockey2
 
Well, then the only remaining difference from your test call is that lcCmd = "makecab /n "+m.lcSource+ Space(1)+m.lcDestination does not put source and destination into quotes, though paths with no space should also not require this.

You're executing with m.loShell.Run(m.lcCmd,1,.T.), have you tried to simply RUN &lcCmd?

Bye, Olaf.
 
Olaf,

RUN &lcCmd tested negative.

Regards,

Jockey2

 
Hi,

O.K. now: just forget about the /n parameter!!

Code:
tcDestinationFile = "recording.cab"  && replace with your desired filename.cab
tcSourceFile = "C:\temp\E170521235835log.txt"  && replace with your sourcefile
tcArchiveDirectory = "C:\Archive1"                  && replace with your desired archive directory. 
** Please note: All files in the destinated archive directory will be erased, only the newly created tcDestinationFile

lcCmd = "makecab "+m.tcSourceFile+Space(1)+m.tcDestinationFile+" /L "+SPACE(1)+m.tcArchiveDirectory
loShell = Createobject("wscript.shell")
lnSuccess = m.loShell.Run(m.lcCmd,1,.T.)
If m.lnSuccess = 0
	=Messagebox("BackUp successful.",0+64,"Backup OK!")
Else
	=Messagebox("BackUp failed",0+16,"Caution")
Endif
Regards,
Jockey2
 
Well, yes, if you had posted the syntax earlier, there is no /N option. /N is just an option of the RUN command, but neither of Shell.Run() nor of makecab, as you post.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top