iexpress hard-coded extraction destination folder? - windows

I'm using iexpress to make a self extracting executable. Is there a way I can hard-code an extraction destination folder (preferably into a temp folder somehwere) so as to not have the extraction pop up the "Please type the location where you want to place the extraced file." dialog?

There's no direct way to do this. (You can see my other answer for a longer explanation about it.)
The easiest solution is to make an IExpress archive that runs an "installation program", which is really just a batch file that copies the extracted files where they're needed.
In IExpress, you'd launch the batch file like: cmd /c persist.bat. And persist.bat looks something like:
#echo off
xcopy /y * "%temp%\persistent\"
del /f "%temp%\persistent\persist.bat"
(The last line is a nicety to hide the fact that you used this batch file to copy the extracted archive.)

Yes, this is possible through the use of an .INF file when you select "Extract files and run an installation command". You must set the .INF file as your Install Program and under the DestinationDirs section you would put the path to the directory you want the files to go to. Here is an example of an .INF file:
[version]
signature="$CHICAGO$"
[DefaultInstall]
CopyFiles=install.files
[DestinationDirs]
install.files=-1,"C:\Program Files\MyCustomDir"
[install.files]
MyFile1.txt
MyFile2.bmp
So this sample shows that the installer will install to C:\Program Files\MyCustomDir. The files under the install.files should list all the files you want to copy to that folder. They must be included in your installer when you are selecting the files to add.

Related

Double click on the zip file has to self-extract the file in the specified path

I have filename.zip file and if double click the file it has to extract the file in the desired location("c:\user\username"). I have tried using the batch file but didnt give me the required result.
#echo on
#set nested=%nested%Z
set _dest=c:\user\username
if NOT EXIST %_dest% md %_dest%
So if i double click on zip file it has to execute batch file to place file in the destination folder path.How can i do that?
If I understand correctly, you simply want to extract a .zip archive to a previously defined directory c:\user\username, when the user clicks that .zip archive.
No, this is not possible.
A .zip file has no default extraction destination. Nor has is a way to execute scripts upon extraction. It is just a container for compressed data. When you click it, your OS runs a program configured to handle .zip files, allowing you to view the contents, extract the contents, etc - but what and how exactly, is up to the user that clicked the file.
What you effectively want to have is an installer. Here are some pointers for options to do that:
Microsoft IExpress
Nullsoft Scriptable Install System (NSIS)
Quasi-installer using 7-zip self-extracting archive

How to use Windows Batch File to mass unzip files and saving them in specific folders?

I got the code to mass unzip from this link. But it unzips everything in the folder where the batchfile exists. I want it to unzip it to specific folders or its individual folders.
Note: my bz2 files are in various folders outside the folder where the batchfile exists.
Here's the script that i used :
for /R "C:\Users\victor\Desktop\MASTERS\color feret\disc 1\data\images" %%I in ("*.bz2")
do ("%ProgramFiles%\WinRAR\WinRAR.exe" x -y -o"%%~dpnI" "%%~fI")
Can someone enlighten me how to do it?
And also if possible, can anyone explain to me what are the arguments for? "x , -y -o %%dpnI " etc. Thanks
You do not need a batch file for this process at all. Start WinRAR, select all the archives you want to extract, click on Extract To in toolbar, select the base destination folder, check the option Extract archives to subfolders in Miscellaneous group and press button OK. That's it.
From a command line in a console window with current working directory being the directory containing all the *.bz2 files to extract:
"%ProgramFiles%\WinRAR\WinRar.exe" x -ad -y *.bz2 C:\Temp\
There is no need for a for loop as WinRAR supports wildcards for archive file names.
And with option -ad the archive file First.bz2 is extracted to folder C:\Temp\First, archive file Other.bz2 is extracted to C:\Temp\Other, and so on. With checking option Extract archives to subfolders in GUI, you use option -ad.
Help of WinRAR contains the page Switch -AD - append archive name to destination path. Click in menu Help on Help topics. On tab Contents open Command line mode and open Commands and Switches. Also text file Rar.txt in program files folder of WinRAR contains a description for command x and the options -ad and -y and all other commands and options for console version Rar.exe.
But if you want to use nevertheless a for loop and want to know what %%~dpnI and %%~fI mean, open a command prompt window, enter either help for or for /? and read.

Copying files from cab to folder

I'm trying to copy the files from .cab file to a normal folder. I don't have extract.exe on my Windows 7. And using xcopy /s .\file.cab .\extracts throws an error saying "Cannot perform a cyclic copy". I've googled the error, but found nothing applicable. The destination folder is empty, and otherwise it can only copy the .cab file but not the files within it. I want to copy all the files within .cab file into a folder. Can someone help? I want this to work on a client environment so I don't want to download any other tools, just command line if I can.
Try any of the following commands. Both should be included in your windows 7
expand file.cab .\extracts
extrac32 file.cab /L .\extracts

batch code to transfer all files and folder from location(s)

I am looking for a batch code that will transfer all files inside folders. Then it will transfer them into the location.
D:\Transfered Files\
And it will keep the exact folder/file names.
For example I want everything transfered from
C:\Users\
C:\Program Files\
I have tried this and it works:
xcopy source destination /Y
Just save this in a batch file of course change the directories as you see fit.
Also note that the '/Y' parameter says that if files exist in the destination overwrite them. If you remove it, it will ask you about each file separately.
If you think this isn't good enough you can use robocopy:
robocopy source destination
Again you need to change the source and the destination directories and put the line in batch file.
I have used both and both works 100%. I have a windows 7 home premium 64x.

How to use WinRAR through Batch?

I need some help with a batch file because I am stumped on WinRAR in Batch, as I haven't done/used it before.
Here is the TREE of my Folders including the batch file:
Each RAR file has the same Directory folder name("vegies" folder).
I would like to be able to extract/copy all folders/subfolders inside of each .rar from "Example/Program_Ex/vegie" back one directory into "Example/Program_Ex/vegies" (Dont forget the folder "vegies" already exists in each RAR which I cannot change as these automatically update themselves.)
So basically with a batch file I would like to:
extract "Example/Program_Ex/vegie/random.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random2.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random3.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random4.rar" to "Example/Program_Ex/vegies"
extract "Example/Program_Ex/vegie/random5.rar" to "Example/Program_Ex/vegies"
I also am trying to not specify a drive, more or less because the batch file will be in the correct folder instead using something such as "CD" or "PATH"?
I have looked at some examples around the web and on here of coarse, but I am still unsure the best way to go about this.
The closest example I can find would be this:
#echo off
set destinationRAR=destination_winrar_file
set source=source_folder_path
"C:\Program Files\WinRAR\WinRAR.exe" a -ep1 -esh -ibck -m0 -r -t %destinationRAR% %source%
(Above from http://fredy-invayne.blogspot.com.au/2013/05/example-winrar-batch-file.html)
Can anyone help give examples on how to implement my question please?
#echo off
for %%a in (
"%~dp0Example\Program_Ex\vegie\*.rar"
) do unrar x "%%~fa" -w "%~dp0Example\Program_Ex" -o+
For each file in the indicated path under the folder in where the batch file is stored, extract the content of the file indicating target folder and selecting that existing files must be overwritten.
You can extract all the archives with a single invocation of WinRAR:
"C:\Program Files\WinRAR\WinRAR.exe" x "%~dp0Program_Ex\vegie\random*.rar" "%~dp0Program_Ex\"
The last argument in the above command line specifies the target folder for all the archives. You may want to add the -o+ switch (must go just after x) to specify that all files should be overwritten:
"C:\Program Files\WinRAR\WinRAR.exe" x -o+ "%~dp0Program_Ex\vegie\random*.rar" "%~dp0Program_Ex\"
If you omit it, the archiver will ask you what to do with existing files, if any.

Resources