Best Batch File IDE for Validator [closed] - batch-file

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:

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.

Downloading file with wrong EOL sequences [closed]

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.

Using bukhantsov.org command line query output with options

I am trying to use the tool here business objects query builder output
And there are virtually no examples, so I'm struggling to make it work. It produces no errors, but outputs no file in the directory where the batch file is, that I can see.
Here is the code inside querybuilder.bat:
set lib=c:\Program Files\Business Objects\Common\4.0\java\lib
java -cp "querybuilder.jar;poi-3.8-20120326.jar;%lib%\*" org.bukhantsov.querybuilder.Program %*
Here is the code inside what I am running, which I've named RunQuery_ALLACTIVE.bat, except of course with my Server, Username, and Password changed for the purpose of this post.
I have this all on one line, with no line breaks.
querybuilder.bat -cms:SERVER -username:OURUSERNAME -password:OURPASSWORD -query:"SELECT * FROM CI_INFOOBJECTS where SI_SCHEDULE_STATUS = 9 order by SI_NAME" -auth:windowsad -excel "Output.xls"
Can't tell if the - options go on different LINES ?
Can't tell if I'm supposed to put output file in quotes, or if it should be an existing file or not?
can't tell if for Windows AD (which we use), I would put "Windows AD" or WindowsAD, I'm assuming no spaces obviously.
Tons of unanswered questions on this tool - it LOOKS cool, but has anyone actually successfully used it? Can't really find comments or history on the 'net..
To answer your questions:
The options go on the same line, not on different ones
As Joe said, you'll need to specify the output file as -excel:"Output.xls"
If you want to use Windows AD, you'll probably need to specify secWinAD (case-sensitive).
If you're not sure about the command line options, I suggest you build up gradually: first only specify the required options, then add the optional ones one by one so you know which one is giving you problems.
Also, I noticed that the download page contains a version compiled for XI3.x and BI4. Make sure you use the correct version, corresponding to the version of BusinessObjects you're using. Also, verify the path in the batch file to see if it points to a valid folder containing the JAR files for the BusinessObjects environment.
Update:
I just noticed that the same author/developer created another application (GUI, not command line) that might be a bit easier to use. Have a look here.

How to refactor a Windows batch script littered with GOTOs?

I have to maintain a batch script of about 3500 lines littered with GOTO. Seems that the original "developer" hasn't heard of this famous paper and modular programming.
What the script does?
The script deals with the (silent) installation/uninstallation/reinstallation of several programs using different options. It could be split in several files that deal with each program in part. The problem is that if you're trying to take a part in another file that part will still GOTO another section that needs to be in the original script.
Refactoring?
Normally you wouldn't do a refactoring without having automated tests (so you can be sure you didn't break anything), but I don't know how to do it. There's no testing framework for that.
Partial Solution
I have come up with a partial "solution" that is some kind of adaptation of characterization tests (from Working Effectively with Legacy Code by Michael Feathers) and approval tests:
- create another script: test.py that replaces all commands (like copy or msiexec) with echo,
- redirect the output to a text file (good.txt),
- change the original batch script,
- run the test.py script again and save the output to another text file (current.txt),
- diff good.txt and current.txt -> if there are no differences then I didn't break anything, but if they are different I need to check if I broke something.
Problem with partial solution
How can I capture and replace all the commands? I could make a list of commands to replace, but there are also a lot of string concatenations to get the name and path of the program to be installed.
CMD level capture/hook?
Is there any way I can hook into the command line interpreter (CMD.exe) so I can replace on the fly all the calls to installers with echo?
Other suggestions?
Do I approach the problem in the wrong way? Can I do it better somehow? Do you have some advice I could use?
You could replace all COPY, DEL or CALL with %COPY%, %DEL% ,...
So you can use the same file for production and also for the tests.
#echo off
if not defined UNITTEST (
set "COPY=COPY"
set "DEL=DEL"
set "CALL=CALL"
)
%COPY% src dest
%DEL% somefile.txt
%CALL% installer.exe
And from your unittest.bat, you could start it via
#echo off
set "COPY=>>trace.log ECHO COPY"
set "DEL=>>trace.log ECHO DEL"
set "CALL=>>trace.log CALL ECHO "
del trace.log
set "unittest=Active"
call production.bat
fc good.txt trace.log
I'm not an expert in Batch, but I have done my fair share of it. With that said, I can offer a few tips.
Forget trying to do it all at once. Batch is very hard to debug. Echoing out to a log file helps a lot, but it will not capture everything you need if something goes wrong.
Work on breaking out the exe and msiexec calls into self-contained scripts. It is much easier to test the small script for the functionality you desire. Once you have that working, it is simple to call that script from the "Master" script.
Establish a good protocol for passing args to, and return codes from the smaller scripts. If there are common settings needed to be used for all the scripts consider using a central settings file.
GOTOs are not the devil, unless they pass control all over the place. Normally there are two good reasons that I know of to use GOTO’s.
Skip past a block of code that does not need to run.
To SET values into variables. Note there is a bug that can prevent variables from having their value set from within an 'IF' statement block. That little bug caused a big headache for me at one time.
Calls to a label might be better option at times.
Depending on how far back the legacy support is required, consider using Powershell when possible. The power and debugging capabilities of Powershell far out way the benefits of simple scripting of Batch. Which at 3500 lines simplicity has already been lost. You are already looking at Python, so maybe that could be used instead.
If you need a break point, use Pause. ECHO all the settings you need to examine right before the pause. This is as close to a break point I have found for batch.
Echo the command you intend to run to a log file and actually run it.
Write small verification scripts to be used independently or with the “Master” script to confirm you are getting the results you are expecting.
Use the right tool for the job. I like to use EditPadPro, RegexBuddy, and BeyondCompare for batch editing and comparing differences. There free tools that can be used too NotePad++ and Windiff. Making many edits in a file of that size is best handled by a good editor. IE inserting an echo at the beginning of a line that calls a cmd.exe.
Remember it is scripting not programming. While there is a lot of overlap of the two, the same exact approach to a problem may not be viable between the two.
Always make a backup copy of the scripts as a whole before mucking around. A fallback position is greatly appreciated when there is one small bug that you can’t find.
If it ain't broke... well you wouldn't be working on it if everything was working just fine.
Always test changes. And when you are done test it again. After that have someone else test it.
Just my .02. I’m sure someone else can chime in with more advanced advice. My knowledge on Batch has been acquired from the school of hard knocks, supplemented by ss64.com

How do we write a program in Command line development environment?

I have been writing my code in IDE,I just read that there also existed a Command Line Development Environment in which the code is written in DOS.I googled but found no results on how to use the command line development environment.My OS is Windows XP.I would be very thankful for your help me write the hello world program in DOS and also explain how to run it.
You simply use whatever text editor you like to create the C sourse file(s) then invoke the compiler command line(s) to compile and link the program (typically, an IDE is doing exactly that, but in a behind-the-scene manner). How the command line is invoked depends on the exact toolchain you're using.
You might also need to set up an environment for you particular compiler toolchain (the right paths and various other env variables might need set up).
For Visual C++ the environment might be set up using a batch file installed by Visual Studio:
vcvarsall x86
Invoking the compiler could be as simple as:
cl helloworld.c
or for C++ (for some reason it issues a non-fatal warning if you don't give it an option configuring details about how it should implement exceptions):
cl /EHsc helloworld.cpp
The particulars are very dependent on the compiler you're using - you should read the docs for that compiler.
Also, the options you use depend on your particular situation and needs. Scripts/batch files and/or makefile can help you manage the complexity of the options you might need to use.
DOS is not dead.... yet!
fahad
There are a number of methods by which you can enter code in DOS (see EDIT further on down).
(1) You can send keystrokes directly to a file
You do this by redirecting output to CON (the console) to a file. The only oddity of this method is that you end the 'session' by entering a CTRL-Z when you are finished.
It's basic, but this is how it goes.
Firstly, suppose you want to display "Hello World" on the screen, a simple batch file containing the following two lines is all that is required:
#echo off
echo Hello World
The '#echo off' is commonly found at the start of all batch files. It simply instructs the command interpretter NOT to display each command as it is being executed (or parsed).
One more thing before we start. Throughout this answer, I will assume your program is named 'helloworld.bat'.
Enter the following lines one after the other pressing the ENTER key at the end of each line:
copy con helloworld.bat
#echo off
echo Hello World
^Z
The '^Z' is displayed when you press the CTRL-Z key combination (don't forget to press the ENTER key as well).
When you press the ENTER key after CTRL-Z, DOS displays the familiar '1 File(s) copied' messege.
You can now execute the batch file program by simply entering the program's name like this:
helloworld
And DOS will display the following:
Hello World
It can't get any more basic than that.
(2) You can use DOS' EDIT program
This is a DOS based IDE retained from around the mid-90's. Simply enter the following command:
edit
And EDIT will open in the same DOS window. When you close EDIT, you are returned back to DOS again.
EDIT also works with your mouse.
Once EDIT opens, enter the following two lines of code:
#echo off
echo Hello World
Then, click on [File], [Save], type: 'helloworld.bat' in the "File Name" input field, use your mouse to change directories in the "Directories:" pane if you want to, then click [OK]. To return to DOS, click [File], [Exit].
EDIT version 4.5 (I think) was context-sensitive and displayed code using different colours to seperate key word, different data type, symbols etc.
(3) Use Windows' built-in Notepad
This is simple. At the command prompt, enter the following command:
notepad
And Notepad will fire up. It's a simple text editor and does the job when entering small programs.
(4) Use Notepad++. It's FREE!!
Notepad++ is the programmer's choice. It's free, full of useful features and customisable. Find it on the net by searching for "notepad++".
From your comment, "Just some knowledge so I can say that I know one way to do programming without IDE" I would say learn to write simple batch files. They can be run from Explorer but they exist as a holdover from the DOS days.
Start a command prompt window (Start->Run->'cmd'), this will open a window and show a prompt, most likely "c:\" or some other path.
Type the following command (followed by )
echo "Hello World"
You should see:
"Hello World"
c:\
Now, using whatever editor you'd like, create a text file with that command as the only line. Name the file "hello.bat". When you are at the command prompt you can execute the batch file like so:
c:\hello.bat
"Hello World"
c:\
You have now programmed using the DOS command line. For more commands and such, start with the help system.
c:\help
Which will display all the available commands for your batch file.
Microsoft has an online reference here.
DOS is dead for all practical purposes. Under Windows your options boil down to the following:
Use an IDE. Visual Studio is one example, Qt another. You can write programs for the commandline with an IDE.
Use a proper text editor, build tool and other helper tools. You might use gvim for editing code, make for building your project and git for version control. You might as well use the GNU coreutils for other helpers, or maybe even the entire cygwin package.
Bro, use gcc compiler for which write ur code in any text editor then compile ur code in windows shell or u can say command line environment.
Look!
Prompt:/> gcc source_file_name.c
This command compiles ur code,
If there is any error, u will get dispalyed with line numbers,
now, every program creates its exe file by the name a.exe by default.
To, get the output of ur program,
Prompt:/> a.exe
O/P
Hello World!
To change the name of the exe file there is also a command..

Resources