How to run exe before or after "RunProgram" from 7zip sfx files setting on config.txt? - windows

I am using 7zip to pack an installation (im using 7z because i need it to work in linux and windows).
From what i've been reading the config.txt file can contains this:
;!#Install#!UTF-8!
RunProgram="Installer.exe"
;!#InstallEnd#!
But what if i need to run another exe before or after running installer.exe? Is it possible like it is in NSIS?

You can specify another progrem in 'RUnProgram' config parameter. Lets say its some .bat file. At the moment program is run, files are already extracted at TEMP location. As your .bat will run then, it can call Installer.exe once script is finished preparations.

Related

7zip SFX not extracting files

I'm trying to create a SFX file and run a vbs afterwards.
Here's my config file:
;!#Install#!UTF-8!
InstallPath="c:\\windows\\temp\\"
ExecuteFile="cscript.exe"
ExecuteParameters="c:\\windows\\temp\\script.vbs"
;!#InstallEnd#!
The .7z archive is not corrupt, I cn=an open and extract files.
here's how I created the .exe:
copy /b 7zS.sfx + config.txt + SylinkReplacer.7z SylinkReplacer.exe
When I run it a cmd windows flashes I have the feeling it's trying tu run the vbs but I can see it has not been extracted in C:\windows\temp.
I ran process monitor and apparently it extract the files in my users' %appdata% within a temporary folder named 7zNNNNNN which gets deleted afterwards.
Any suggestion? Thanks
I found a way to make it work (I actually found it on stackoverflow but now I can't find it anymore).
;!#Install#!UTF-8!
ExecuteFile="ReplaceSylink.vbs"
;!#InstallEnd#!
This is not the best solution since I wanted it to run it with cscript (console) while on many servers the default engine is wscript (GUI).
I'll use something to force cscript like this on this one http://www.robvanderwoude.com/vbstech_engine_force.php

SFX with 7-zip : Is it possible to run a included .bat file *before* extracting the files?

I'm creating a SFX executable with 7-zip (command line version) and the 7zsd.sfx module. My current config file looks like this :
;!#Install#!UTF-8!
Title="Test"
BeginPrompt="Test"
CancelPrompt="Do you want to cancel the extraction?"
ExtractDialogText="Please, wait..."
ExtractPathText="Please, enter the extraction path:"
ExtractTitle="Extracting..."
GUIFlags="8+32+64+256+4096"
GUIMode="1"
InstallPath="%%S"
RunProgram="test2.bat"
;!#InstallEnd#!
Is it possible to run a program before extracting the files? Currently, test2.bat is ran once the files are extracted. I'd like :
The user click "OK"
test1.bat is executed
Files are extracted
test2.bat is executed
Using WinRAR's SFX, there is a presetup option. Is there something similar using 7-zip and 7zsd.sfx?
One workaround I found is to extract the files to a temporary folder instead of the final target, run the first .bat file, xcopy the temp folder to the real target and finally run the last .bat.

Batch file to rar and password (very specific)

I was trying to make a batch file that compresses a specific folder (using winrar) to a specific location (not the same as the folder location), password (that I can choose myself) protects it AND does all of that without a cmd screen popping up.
I have very little knowledge of programming and managed to get some things working, but not all at the same time and in the same batch file.
Also to rar that file do I need Winrar to be installed on the computer or can I reffer to the rar.exe (copied from the Program Files Windows folder to a different location)?
AFAIK it's not possible to run a a bat file without a visible CMD window without using any additional tools. Here's a link to a post how to run a hidden console: https://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way
It is possible to use just the rar.exe but I would use 7zip instead. The performance is way better, it's also portable and you have many options in the command line. So your project would contain the bat file itself, the vb script file and the 7z.exe (or rar.exe). If you want, you can even create a single .exe file out of these three by creating a SFX file: http://www.7zsfx.info/en/
Hope I could help you.

how could I run/execute a text file as a exe using batch

I need to know how I could make a batch file that would execute / run a txt file as if it was an exe file. Does any one know what I could do or try. I am using windows 7 ultimate 32 bit. The txt file is an exe just with the .txt extension.
If it is an EXE, why is it named .txt?
Sometimes EXEs are renamed to be able to send them per EMail (some Email-servers are blocking EXEs for security reasons)
Best way is to rename it to .exe
If you really want to stay it as .txt make a copy:
copy file.txt file.exe
file.exe
Note: Don't run any executable if you don't fully trust the source!
One way might be to alter the HKEY_CLASSES_ROOT\txtfile\shell\open\command registry key to change what happens when .txt files are opened.
The default setting is to open with notepad.exe
%SystemRoot%\system32\NOTEPAD.EXE %1
Another way could be to rename the file to.exe, run it, rename it .txt when finished.
There's no need for copying the .txt file to a .exe extension.
This only works if the file is executable
Simply put in batch script:
call yourfilename.txt
or just open CMD and type the same thing, this works only if the .exe file
was renamed to .txt extension, same works as for .run, .dat, .bin, .bmp and
so on, for example:
call chrome.x
or lets try starting CMD with .bmp extension
call cmd.bmp
This will work on all the files that have executable code, other files will not work!

How to register DLL from .bat file in Windows 7

As part of a poor-mans installation (on Windows 7) I need to register a DLL from a .bat file. I provide the user with a set of files that make up the application, tell them to copy them to some (any) directory, then, as the 1st part of the install, tell them to execute my register.bat file which invokes regsvr32 on the appropriate DLL(s)
This fails with 0x80004005 (permission) error. I then try running the .bat file as an Admin. This doesn't work as it opens the command prompt in \windows\system32 which is not where the DLLs to be registered are located. As I don't know where the user has placed the register.bat file I can't put the path to the DLL files in the .bat file.
Any thoughts?
Try using %~dp0 to get the folder the batch file is stored in, like:
regsvr32 %~dp0\mylibrary.dll
You can get and use the path of the current directory like this:
set "FullPath=%cd%\Test.dll"

Resources