Parameters for extracted .exe setup - windows

I have a SampleApp.exe. When I double click it, it extracts itself into a folder (lets say a folder name SampleAppFolder and YES it do ask for a folderpath) and starts a Setup.exe from that folder (Setup.exe is extracted in SampleAppFolder). I want to run SampleApp.exe in silent mode. So I created a batch file as
"D:\Softwares\SampleApp.exe" /S /V" /quiet"
Everything gets extracted in SampleAppFolder silently but when it triggers Setup.exe from the folder, I am able to see a window. But I wanted to run even this .exe in silent mode. So I guess I need to pass some parameters for this setup.exe also. But I am not sure how. Any pointers please?
On more thing, I changed the above query as
"D:\Softwares\SampleApp.exe" /extract"C:\Users\MyName\Desktop\TestFiles123" /S /V" /quiet"
I thought the extraction path will change, but nothing happened and the files got extracted to default location again. Any pointers? Thanks

Try opening it up in 7-zip. It can extract files from most installers and you can choose where to extract them (and which ones if you're only looking for a couple).
7-Zip Website Link

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

Using CMD to open an .exe file, from the same directory?

Im trying to make this launcher for my game.
But I can't seem to find anywhere, how to open a file. Without specifying the location.
Like I want it to run a file, from the same folder as the .cmd file is in. (The one I created).
Been searching for ages, without finding out how.
Reasoning: The user is able to change where the game is going to be installed. So I cant specify a location..
Simply open Command Prompt. Then Drag and Drop your .exe file to the console. (This will copy the location of the .exe file to the console) Then just press "Enter". Then your .exe file should be running.
References http://www.howtogeek.com/209694/running-an-.exe-file-via-command-prompt/
Hope it helps
The argument %0 of a batch file references the name of that batch file. So to run an exe located in the same folder where your batch file is, use:
%~dp0program.exe
The ~dp expands the argument %0 to a full qualified path name - including a trailing \ that's why there is no \ between %~dp0 and program.exe
Details about expanding variables can be found by typing help for on the commandline
Turned out, it was just me being foolish.
Forgot that I could just type in the name of the file.
Instead of doing something big out of it.
Thanks #ByteHamster for refreshing my memory :)
"Quote" ByteHamster: If you are in the same folder, just type in the name of the exe file.

Batch: Running exe, copying file to appdata, and put it in startup

For example, I have 2 exe's. Let's call them 1.exe and 2.exe, to keep it simple.
And I want to make a zip file, with 3 things in it, 1.exe, 2.exe and setup.bat.
First off, I want to know that the user is okay that we start the first exe (1.exe). So we type:
#echo off
cls
echo Are you sure you want to install 1.exe?
echo If not, click exit right now. If you are okay with it,
pause
Here comes the first question. So we want to start 1.exe. How do I start 1.exe, that is in the same folder as the bat file?
Okay, lets continue. When 1.exe is finished, I want to copy 2.exe, place it in %appdata%, and then add it to startup. And that's the second question. How do i do that.
So the questions are:
How do I start 1.exe, which is in the same map as setup.bat
How do I copy 2.exe which is in the same map as setup.bat to %appdata%
How do I properly add 2.exe which is in %appdata% now to startup?
Note: Just using C:\documents and settings\all users\desktop\1.exe isn't going to work. I want it to work in all sorts of languages, and in some languages the folders might be called different.
1.exe will run 1.exe, just like on the command line.
copy 2.exe %appdata% will copy 2.exe.
I don't know what question 3 means.
Define "work in all sorts of languages"? If you need to pass in an argument to the batch file, do so: http://commandwindows.com/batch.htm
You are right you should never hard code "Documents and Settings" or "Program Files" in a BAT file, because these folder names don't "work in all sorts of languages". You need to refer to them using special folder ids or environment variables.
In your case, you need to create a program shortcut (.LNK file) in the startup folder. There are two parts.
creating a shortcut. Unfortunately there is no way to create a shortcut using only windows commands. You need to rely on a third party tool, there are many free command line tools that may do it; or write your own.
locating the Startup folder and placing the shortcut there. There are two startup folders. The common startup and the user startup folder. Choose one. Then, you need to use either the %ALLUSERSPROFILE%\Start Menu\Programs\StartUp or the %USERPROFILE%\Start Menu\Programs\StartUp.
So putting all pieces together in your SETUP.BAT , it would look something like this...
#echo off
echo Are you sure you want to install 1.exe?
echo If not, click exit right now. If you are okay with it,
pause
1
copy 2.exe %appdata%
makelink %appdata%\2.exe %USERPROFILE%\Start Menu\Programs\StartUp\2.lnk
One suggestion. Avoid all this mess. It seems to me that you need to install a program. If so, I'd recommend you to try Inno Setup. http://www.jrsoftware.org/ .
Inno Setup is a free installer for Windows. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.
...
Supports creation of a single EXE to install your program for easy online distribution. Disk spanning is also supported.
Standard Windows 2000/XP-style wizard interface.
Customizable setup types, e.g. Full, Minimal, Custom.
Complete uninstall capabilities.
Installation of files: Includes integrated support for "deflate", bzip2, and 7-Zip LZMA/LZMA2 file compression. The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX's and type libraries, and install fonts.
Creation of shortcuts anywhere, including in the Start Menu and on the desktop.
Creation of registry and .INI entries.
Running other programs before, during or after install.
...
This should do what you want.
#echo off
cls
echo Are you sure you want to install 1.exe?
echo If not, click exit right now. If you are okay with it,
pause
start /wait 1.exe
xcopy 2.exe %appdata% /y
reg add HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v "2" /d %appdata%\2.exe
The last line will make a reg entry instead of copying it to the startup folder which will not create a shortcut on the desktop and you don't need anything more than batch.

Why does 7zip Ignore my InstallPath when making a SFX installer?

Currently, I am making a SFX with 7zip using the following config:
;!#Install#!UTF-8!
InstallPath="C:\\test"
GUIMode="2"
RunProgram="7z465.exe"
;!#InstallEnd#!
I then package 7z465.exe into Setup.7z, and then call the following line in a batch file:
copy /b "C:\Program Files\7-Zip\7zSD.sfx" + config.txt + ".\Release\Setup.7z" .\Release\Setup.exe
When I run the resulting Setup.exe, It extracts fine and launches the 7z465.exe as well, but it is still extracting to some 7zip temp folder for the current user and not C:\test!
Running as administrator seems to have no effect either.
Anyone have any idea why this is happening?
Use modified 7zsd.sfx from http://7zsfx.solta.ru. InstallPath only works with the modified package.
I never found out why this was happening, and after hours of struggling with it, I switched to WinRAR. Granted, its got some quirks of its own, but I was at least able to figure those out and get it running for my needs.
Would recommend WinRAR over 7z for SFX stuff.

CMD: Bat to Exe Converter - Temp directory problem

i am using 'Bat to Exe Converter' to convert my batch files to exe format.
Now, i am running into some problems.
Whenever i convert something, and i set 'Working Directory' to 'Current Directory', and i start my exe in echo on mode, this is what i end up with to check if there is a specific file in the directory of my exe:
the actual command: if not exist "%~dp0\file.txt" goto :nofile
output: if not exist "C:\Users\MyUser\AppData\Local\Temp\4CBC\\file.txt" goto :nofile
Can anyone help me with this? I don't want it in the temp directory, i want it to be in the directory of my exe.
Thanks.
Without having Bat to Exe changed by the author, I think you have two options:
Remove the need for accessing %~dp0
Perhaps you can merge file.txt with the include option of Bat to Exe into the EXE file. If so, "file.txt" will automatically be unpacked in the current directory when running your compiled exe, and you can it access by %CD%\file.txt.
Get %~dp0 from outside and pass it to the exe as a command line parameter.
This can be done by a simple starter bat file that resides in the same directory as your compiled main batch file. This script schould contain the line
YourCompiled.Exe %~dp0% %%*
Your compiled exe then gets its directory from %1. So you cannot pack everything into one exe, but the main portion of it, perhaps that is sufficient for you.
Well, apparently your batch to exe converter simply packs the batch file and extracts it to a temporary directory prior to execution. Very simplistic, hard to get wrong (compared to actually understand the batch file) but it introduces errors such as the one you're describing.
Your best bet is probably to use another batch to exe converter; some of them are actually a little more sophisticated.
Generally, this is not a good idea. firstly, its prone to errors and instability of the converter on different cmd features. secondly, a determined hacker can still decode what you are doing with the batch. My suggestion, if you are so afraid of people looking into your batch,
1) let only the people who are authorized to use your batch to use it
2) give them the correct permissions.
OR, don't use batch at all
1) create a central interface such as a web interface, where all tasks to be done goes through that interface, like using an ATM machine where only buttons are allowed and all the available user options can be done by pushing buttons...etc..
2) authenticate your users through a central authentication system, eg Active Directory, or LDAP or a database.
This is an 2.5 yr old subject but there is an answer to this so I'm posting for anyone else that happens to find this in a search.
B2EC written by Fatih Kodak, has an option to "Submit current directory".
When this is used, you can reference %1 in your batch file to get the path of the EXE that was executed (instead of the path of the extracted BAT that is really being run).
Hovering over that option in the UI shows "Submit the current working directory as the last parameter". The "last parameter" in my use has always been %1 but you can test your code to be sure.
The latest version, 2.1.4 at time of writing, of Bat to Exe by Fatih Kodak creates an Environmental Variable at runtime that can be substituted in place of %~dp0 to reference the Exe's path. Therefore, you can simply replace %-dp0 with %b2eprogrampathname% in the original batch file.
You can use external folders with f2ko's batch to exe converter. Having
a separate folder for subroutines can neaten up a project folder.
To call mysubroutine that is located in mysubroutinesfolder\mysubroutine,
...
pushd mysubroutinesfolder
call mysubroutine
popd
...
The call can be made a one liner:
call xqt mysubroutine
where xqt.cmd is a program that does the call for you:
pushd mysubroutinesfolder
call %*
popd
exit /b
(the %* means "all of the arguments").
In this way your batch programs run as batch, and UNMODIFIED they will
compile with the bat to exe converter, creating a completely folder independent executable. Select "temporary directory",
and include all of the subroutines/executables in your mysubroutines folder
by "selecting them all" with your cursor as usual, then hit "copy".
Be sure to include the xqt.cmd program too; place it "outside" of your mysubroutines folder. Make sure that is is accessible by your main program. Remember to select x64 if you
are runnning on a x64 machine, or the executable will not find SYSTEM32
files. You can find f2k0's batch to exe converter at:
http://www.f2ko.de/programs.php?pid=b2e
Try this development environment for batch scripts, Batch Compiler . It has everything you need to develop a batch program.And compile into stable stand alone executable (Exe).
Friendly user interface.
Debugger, Check your code for syntax errors.
Powerful, versatile compiler.
Allows mouse input in batch files.
Use Windows Common Dialog Boxes.(BrowseFiles,BrowseFolders)
Draw graphics in batch files.
Reverse engineering proof encryption of source code.
Include Company name, Copyright info and Version info.
Make invisible(silent) executables.
Executables with administrator privileges.
Run & debug your script while editing.
Embed resources with executable.(music,images,files)
Advance Commands (BrowseFiles,LaunchSilent,MouseCMD)
Stand-alone executables.No dependencies needed.
Executables are woking on almost all windows operating systems.(98 to 10)
Quick download : http://bc.gotek.info/files/BatchCompiler159.zip
Cheers!
%cd% will give you the current directory:
if not exist "%CD%\file.txt" goto :nofile
Use %CD% instead of %~dp0.
EDIT:
B2EC is not a real converter. Creation location of equipped .cmd file was chosen to be %TEMP% and this is a good choice. Application just lacks 3rd option for working directory of the script - .exe file directory. I advise you to mail the author about adding this one.
Different paths for .exe and created .cmd lead to information loss, i.e. we are unable to know .exe directory and current directory at the same time without providing additional information to the script (e.g. using environment variable or passing it as first/last argument to the script). This script would need to handle it and we would end writing cmd scripts tailored for this converter, which is bad.
%~dp0 - script directory (%TEMP%/.../) - practically useless
%cd% - working directory (as set up in the converter) - currently there are only 2 options: current directory (working directory of .exe) and temporary directory (actually equal to %~dp0, but without trailing backslash)
I think it can be solved by patching cmd.exe instance in memory to change the script path, but that's B2EC developer's duty.
Side note: Normal executable files can be easily executed with specified 0th argument by providing appriopriate lpApplicationName and lpCommandLine to CreateProcess function. Command files are executed via cmd.exe, so 0th argument cannot be set this way.

Resources