INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

makecab

makecab

(OP)
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 --> vfp

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 https://ss64.com/nt/makecab.html the code should now be:

CODE --> vfp

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)



RE: makecab

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:

http://www.sweetpotatosoftware.com/blog/index.php/...

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.

RE: makecab

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.

RE: makecab

(OP)
Olaf,
1) no spaces in the directory
2) the call to makecab works ok, I tested with

CODE --> vfp

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

RE: makecab

(OP)
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 https://ss64.com/nt/makecab.html 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 --> vfp

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)

RE: makecab

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.

RE: makecab

(OP)
Olaf,

please check https://ss64.com/nt/makecab.html

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

RE: makecab

(OP)
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

RE: makecab

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.

RE: makecab

(OP)
Olaf,

RUN &lcCmd tested negative.

Regards,

Jockey2

RE: makecab

(OP)
Hi,

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

CODE --> vfp

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

RE: makecab

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close