How to write a batch script to call a .exe file? [closed] - batch-file

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I have a .exe file (let's say it's name is XXX.exe) whose job is to clean a text file with all lines starting with %. Usually I call the .exe file in CMD as:XXX.exe clean_text.dat and it does the job.
However I want to create a batch file where the text file's name will be user input and rest everything will be done automatically. I have written a script as:
#echo off
set /p file= Enter filename:
XXX.exe file
After giving the filename (with full path), CMD flashes error saying it can't access to the input file.
I believe the last line is not correctly writtten. Can anyone provide the solution?

Use %file% in the last line. You want the contents of variable file and not the name of the variable to be used as parameter for program XXX.exe.

Related

Lost Source Code of a Batch file that I had eventually converted to an EXE. Anyway to get the source back? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I was working on a little Batch file script that I had converted into an EXE. I had then lost the batch file but I still have the EXE. Is there a way I can convert it back into a .bat file to get my source code back?
All batch "compilers" are just wrappers for the script that extract them to some directory (usually %TEMP%) and run them. The location in %TEMP% is going to vary by which compiler was used, but here are some of the more common ones and where the script ends up getting extracted:
For all of these, my initial script was called raw_script.bat.
Compiler Name
Location
Hidden Folder?
My Script's Location
Advanced BAT-to-EXE Converter
%TEMP%\<string>\tmp<numbers>.bat
Yes
%TEMP%\wxy\tmp94807.bat
f2ko Bat To Exe
%TEMP%\<string>.tmp\<string>.tmp\<string>.bat
No
%TEMP%\3F11.tmp\3F12.tmp\3F13.bat
Slimm Bat To Exe
%TEMP%\<string>.bat
No
%TEMP%\it.bat
BlackHost Bat to Exe
%TEMP%\<string>.bat
No
%TEMP%\cmd.bat
Gotek BatchCompiler
%TEMP%\<string>\tmp<numbers>.bat
Yes
%TEMP%\ytmp\tmp57317.bat
Bat2Exe.net
%TEMP%\<string>.tmp\<filename>.bat
No
%TEMP%\7zS1034.tmp\raw_script.bat
IExpress
%TEMP%\<string>.tmp\<filename>.bat
No
%TEMP%\IXP000.tmp\raw_script.bat
You may have also used some other compiler that does not extract to %TEMP%, and as long as the script takes input from a set /p command that's later used in an if statement and that variable doesn't use delayed expansion, you can use code injection to extract the text of the script:
"=="" call type %0 >"%USERPROFILE%\Desktop\output.txt" & REM
It's REM and not REM. Note the space at the end.
If that crashes the script, the if statement may not use quotes. If that's the case, use
""=="" call type %0 >"%USERPROFILE%\Desktop\output.txt" & REM
instead. Same code as before, just with an extra " at the beginning.

Batch making text file input not copied [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I make a batch file which first creates a couple files, and then opens it
For one file I did
Set txt = (some text) """" & (some more text)
And then it puts that text into a .txt file but, everything after the & doesn't get copied. Only the things in front of it.
I would want to copy the whole thing, not only the things in front of the &
Put carret ^ just before the ampersand & character, it need to be escaped because it have special meaning in windows shell scripting

Windows command line %argument was unexpected at this time (with single percentage!) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm trying to run the following command in a command prompt, with single percentage for the argument, as it should be for command prompt instructions:
for /F %remote in ('git branch -a') do (git branch --track %remote) && git fetch --all && git pull --all
But I still get the following error:
%remote was unexpected at this time.
There's a lot of issues with this "argument was unexpected at this time". I've searched and searched but almost all solutions refer to the same confusion between using % or %%. Double percentages should only be used in batch files. But I'm using the proper notation. Why doesn't it work?
Could it be because of the parenthesis? I don't know if this issue mentioned on Microsoft's website is relevant or not.
Read the Documentation
C:\>for /?
Runs a specified command for each file in a set of files.
FOR %variable IN (set) DO command [command-parameters]
%variable Specifies a single letter replaceable parameter.
Notice how the 3rd line of the documentation says "single letter"
(the complete help text is 153 lines long. I recommend reading it ALL)

how to remove the batch file you just used [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I remove a batch file I just used with a batch code line?
Like a code that does this:
remove thisbat.bat
Thanks in advance.
Some people will tell you to just put
DEL "%~f0"
on the last line, but that usually causes an error in that the BAT file can no longer find itself. You should use the following statement on the last line of your BAT file, because after it hits this line your BAT file is gone:
start /b "" cmd /c del "%~f0"&exit /b
This will launch a new delete process within the same console, thus eliminating any "file can no longer be found" errors.

Saving DOS command to a txt file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I need to save list of DOS commands itself in a text file.
But when I am using
echo copy source_file target_file >> new_command.txt
it is writing the copy command to the file correctly but at the same time it is executing the command.
What I want is that this should only write the copy command to the file without executing it..
new_command.txt should contain
echo copy source_file target_file
I don't know why you want to do this though :)
echo echo copy source_file target_file >> new_command.txt

Resources