Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
When trying to download a file from my GitHub repository using CURL, it always downloads it correctly with all the content fine, except that it uses LF instead of CRLF, which is what I need for windows. This is used for being able to update a batch file automatically, and it worked fine, except this one specific file. This is the file that causes problems (GitHub). When pushing this file from GitHub desktop, I made sure that it was saved as CRLF, but seems like it's somehow ignoring it.
Note: This also happened when using the BITSADMIN tool.
Thank you.
Have a try with changing your usage to include the -B --Use-ASCII option like so:
curl -s -B --Use-ASCII https://raw.githubusercontent.com/L89David/DarviLStuff/master/versions > "!temp!"
It does still appear though that in the first script you haven't terminatinated the last line with a {CR}{LF}
A small tip with importing variables like this, If you change the stored format to:
Set "echoc=59"
Set "pbar=27"
Set "virint=31"
And the file type to bat or cmd, You can easily import them by just calling the file once it's downloaded.
Related
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.
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.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I have a batch file which generate so many erros. I have tried some batch IDE, but no clue which code is wrong.
I need something like netbeans for java, Visual Studio for VB and C#, etc.
What should I use for batch file?
I can't see what is wrong, but the error ie.
'else' is not recognized as an internal or external command,
appears.
It really painful to code without IDE since I need to prepare files and setting so many things to testing. What I need is something like error suggestion like this picture below but for batch file:
So, if my "if else" block is wrong, tell me please that my if else is not proper before I test the batch file directly.
Need suggestion please, maybe online tools is ok. Like HTML validator, JSON validator is ok. I need validator for batch file.
Offline tool or IDE is better.
I suppose you have to remove line breaks between 45 and 46, 40 and 41, 35 and 36, 30 and 31, 19 and 20.
This my sample code works well:
if exist 123 (
echo 1
) else (
echo 2
)
And that code with line break before else generates error "'else' is not internal or external command":
if exist 123 (
echo 1
)
else (
echo 2
)
Here is a way to still keep line breaks - add ^ character at the end of line before 'else' - that also works for me:
if exist 123 (
echo 1
) ^
else (
echo 2
)
I don't know of any IDE (Integrated Development Environment) or text editor which validates batch files and therefore read the comments here very interested.
But even an IDE like VisualStudio or Eclipse does not find all errors in C/C++ code on typing found later by the C/C++ compiler on compilation.
And because of %variable% being expanded before being interpreted by command processor resulting in modifying batch code during execution (more or less), no batch validator can ever find all possible errors which can occur on batch execution.
Well, the usage of a good text editor like UltraEdit highly customized for batch file editing as I have done
with syntax highlighting (not perfect, but perfect is impossible for batch files),
with automatic usage of OEM code page (instead of ANSI as for other text files even in same instance),
with automatic indent and unindent of blocks,
with the possibility to reindent a batch code block or an entire batch file by usage of a single command,
with auto-completion for often needed commands,
with using smart templates for often needed structures like for IF and FOR commands,
with a function list listing all well defined labels and subroutines,
with the possibility to run edited batch file from within UltraEdit with or without parameters via a user tool and
with the possibility to write a script for checking syntax of a batch file or running a third-party tool to check the batch file syntax (not used by me)
is definitely a big help on efficiently writing batch code. But testing the batch files in a command prompt window with various input data and sometimes with echo being enabled to see what is going on during batch execution is very often nevertheless necessary.
I'm not sure whether this is what you are looking for.
Appreciate your reply if this helped.
Take Command/ Batch Debugger
Or if you need only a text editor, I'd suggest Notepad++ Very simple and straight forward application.
Take a look at Batch Compiler it is a complete IDE with a built in compiler and debugger. You can compiler your batch scripts to stand alone executables with version info, admin manifest, silent console mode and so many features. The best thing about Batch Compiler is it's free.
Screenshot of the IDE:
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 6 years ago.
Improve this question
I have a computer that does not show all of the files in windows explorer or when doing a dir from command line. When browsing in windows explorer - it goes up until file "cat.doc" then no more. If I do a dir in my documents - it will list until it gets to "cat.doc" and then next line says "File Not Found".
If I go to microsoft word- and type the filename exactly of a file not shown - it will open. Example - "Dog.doc" will open in word if I type the filename in the open file dialog box even though it doesn't show in windows explorer or the dir command.
Thanks for any help in advance!
As it turns out - a chkdsk was able to fix the problems in just a short amount of time. It spit out two lines saying repaired index - didn't write down exactly what it said. However, when logged in - it was working properly again. Thanks for your thoughts!
One problem that fits symptoms like these is the presence of a file with one of the names reserved by Windows: CON, NUL, AUX, and so on. In this case, CON might explain why it cuts off at the letter C. You might experiment with creating files called COM and COO and see if the cutoff happens right between them.
If there is indeed a file called CON in your directory, you can delete it following the advice on Server Fault #282194:
Del \\?\C:\Your\Directory\CON
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am trying to parse a txt file and I want to reference it relative to my current directory location. If I put the file path in completely it will work but it I try to use
..\src\test.txt it wont find it. Is this not the proper way to reference a file relative up one directory?
Any help would be appreciated
If you put "..\src\test.txt" in a string constant, you need to double all the backslashes so that "\t" and "\s" are not interpreted as escape sequences. (Or you can use forward slashes instead, which is more portable.)
It will depend on what the current working directory is set to. By default it is the directory the executable resides in if you double-click the app from Explorer, or the current path the shell is in if started from a command prompt.
If test.txt is in c:\code\app\src and your application is in c:\code\app, the relative path "..\src\test.txt" is going to end up c:\code\src\test.txt (if launched from explorer).
Try printing the output of _getcwd before you try opening the file to verify what directory is the current working directory.
Assuming that your directory structure looks like:
project
+---src
| test.txt
| proj.c
\---bin
a.out <- Working directory
your relative path is correct; your working directory is actually on the same level as the text file.
If you really mean that the file is up one directory as you stated, like this: (Note: This is an awkward project structure)
project
\---src
| test.txt
| proj.c
\---bin
a.out
or like this: (makes more sense)
project
| test.txt
+---src
| proj.c
\---bin
a.out
Then the path you need is "../test.txt" or, equivalently, "../../project/test.txt"
A better location would be in a data directory, so your path would be "../data/test.txt"
I guess this is a windows VS vbuild (given the back slashed path)
VS will have put the binary in something like project\bin\debug. And when you run it in VS it will set the current WD to the location of the binary.
so
a) copy the file to the right place
b) change the project properties debug setup to say set the current path to the place where you expect the file to be (relatively)