BFarchive Usage

(imported topic written by blinkxzero)

I’m fairly new to writing Fixlets, so I may not know all the best practices and ways to go about creating them. That being said, I’m trying to figure out the correct way to use the BFArchive.exe tool in order to accomplish a simple task.

I’ve seen the documentation available at:

http://support.bigfix.com/cgi-bin/kbdirect.pl?id=452

and also have searched the forums for the proper usage, but I can’t seem to pin it down.

So I really have two questions:

How do I go about invoking BFArchive.exe? Do I need to download it to the client computer via the fixlet and then run it or is this something that should be working straight from the action script?

Here is my work in progress for this fixlet (took out specific names / sizes to generalize):

For the record, the contents of bigfix.tmp is about 15 files (35 MB in size) and there are no subfolders.

// download tmp file from server download <server>/bigfix.tmp 

continue 

if 
{(size of it = <size> AND sha1 of it = 
"<sha1>") of file 
"bigfix.tmp" of folder 
"__Download"
}   
// extract tmp to __Download folder extract bigfix.tmp   
// copy old files from previous installation to a backup folder waithidden cmd /c xcopy 
"C:\Program Files (x86)\program" 
"C:\Program Files (x86)\program\backup\"   
// delete original files after backup waithidden cmd /c del /q 
"C:\Program Files (x86)\program\"*.*   
// copy all files from __Download folder to destination waithidden cmd /c xcopy /y /s /c /i __Download\*.* 
"C:\Program Files (x86)\program\"   
// delete tmp file that gets copied over  delete 
"C:\Program Files (x86)\program\bigfix.tmp"

This works, except I want a better way of copying the files to the folder without copying -everything- from the __Download folder. I don’t want any residual files or garbage thrown into the install folder.

If using the above method, I want to extract the bigfix.tmp file to __Download\Program\ , and then copy that directory’s contents, but I don’t know the best way of doing this.

However, BFarchive.exe seems the best way to do this task.

Ideally, I’d like my fixlet to do something like this:

// download tmp file from server download <server>/bigfix.tmp 

continue 

if 
{(size of it = <size> AND sha1 of it = 
"<sha1>") of file 
"bigfix.tmp" of folder 
"__Download"
}   
// copy old files from previous installation to a backup folder waithidden cmd /c xcopy 
"C:\Program Files (x86)\program" 
"C:\Program Files (x86)\program\backup\"   
// delete original files after backup waithidden cmd /c del /q 
"C:\Program Files (x86)\program\"*.*   
// extract tmp to program folder BFArchive -x __Download\bigfix.tmp 
"C:\Program Files (x86)\program\"   
// delete tmp file delete __Download\bigfix.tmp

However, whenever I try and save something like this, BFArchive throws an error as Unknown Action command. I think I am missing a step or logic when using BFArchive.

Any ideas or am I going about this the complete wrong way?

(imported comment written by jeremylam)

Yes, you have to download the BFArchive utility manually and run it as a normal command line executable. It is not integrated into the client.

At the beginning of your action add this:

prefetch BFArchive.exe sha1:5ceb34639963efd1f8f405336e584e7d02469dc1 size:399872 http://software.bigfix.com/download/bes/util/BFArchive-8.0.0.0.exe
 
utility __Download\BFArchive.exe

And then use this command to extract tmp to program folder:

waithidden cmd /c __Download\BFArchive.exe -x __Download\bigfix.tmp "C:\Program Files (x86)\program\"

(imported comment written by blinkxzero)

Fantastic!

Here’s my action script if anyone is interested for reference:

prefetch BFArchive.exe sha1:5ceb34639963efd1f8f405336e584e7d02469dc1 size:399872 http:
//software.bigfix.com/download/bes/util/BFArchive-8.0.0.0.exe prefetch bigfix.tmp sha1:<sha1> size:<size> http:
//<server>/bigfix.tmp   utility __Download\BFArchive.exe   

continue 

if 
{(size of it = 399872 AND sha1 of it = 
"5ceb34639963efd1f8f405336e584e7d02469dc1") of file 
"BFArchive.exe" of folder 
"__Download"
} 

continue 

if 
{(size of it = <size> AND sha1 of it = 
"<sha1>") of file 
"bigfix.tmp" of folder 
"__Download"
}   waithidden cmd /c xcopy 
"C:\Program Files (x86)\program" 
"C:\Program Files (x86)\program\programBak\"   waithidden cmd /c del /q 
"C:\Program Files (x86)\program\"*.*   waithidden cmd /c __Download\BFArchive.exe -x __Download\bigfix.tmp 
"C:\\Program Files (x86)\\program\\"   delete __Download\bigfix.tmp delete __Download\BFArchive.exe

Note: I used escape characters for the target directory of the extract. Not sure if it’s 100% needed, but the results seem to work well.

Does this fixlet look proper in terms of “best practices” ? Mainly I’m referring to the prefetch section and if I need to clean up the download directory (the deletes at the end) after the Fixlet does everything.

Thanks for all your help!

(imported comment written by jeremylam)

You probably don’t need the two “continue if” statements since I think the prefetch lines already validate the file, and I think the download directory is self-cleaning also. But there’s no harm in being thorough.