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 have two numeral values, %Points%, and %PCP1%.
I wish to have something like:
IF (%Points% < %PCP1%) (
cls
echo Not enough money!
echo Hit enter to return home
pause
goto 2
)
ELSE (
echo Confirm Purchase? Your Points after this purchase will be (%Points% - %PCP1%)
pause
)
It doesn't work. Please help. Thanks!
The less than operator is LSS i.e.:
IF (%Points% LSS %PCP1%) (
Other Operators are:
EQU: equal to
NEQ: not equal to
LSS: less than
LEQ: less than or equal to
GTR: greater than
GEQ: greater than or equal to
Related
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 1 year ago.
Improve this question
What does this piece of code means? Could someone explain it to me?
set "txt=!txt:~0,-1!"
#echo off
setlocal EnableDelayedExpansion
set "txt="
set input=input.txt
for /f "delims=" %%a in (%input%) do (
set "txt=!txt!%%a,"
)
set "txt=!txt:~0,-1!"
>new.txt echo !txt!
This code returns a substring of the contents of the variable txt.
The two numbers indicate the start and end location of the requested substring in the original value of variable txt.
A negative value for the second number means count backwards.
So in your example the returned value will be the contents of variable txt without the last character.
For more info on this syntax see:
https://ss64.com/nt/syntax-substring.html
It does mean: 'cut last character from variable !txt!'
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 1 year ago.
Improve this question
here's the story
so I want to create a batch file that can record attendance
so here's my problem- how can I enter random numbers on my batch file?
wait here's another problem: what I going to do to save the random number entered on the batch file to a folder like this-
MD [random number]
i'm not quite sure if this is what you mean but I think I have an idea;
In order to create a random number in batch you want to use "%random%", without the quotes of course.
This will generate a random number from 0 to 32767.
If you want to set this number to a variable you want to do:
set /a var=%random%
So for example you would have:
:createFolder (
set /a var=%random%
md %var%
)
If you need anymore help, feel free to contact me, or you can send me a message on Fiverr if you need me to write you up a program :)
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 2 years ago.
Improve this question
What is wrong with this code? it is supposed to print hello world
#echo off
set message = Hello World
echo %message%
I wrote it in notepad, and I saved it as first.bat, but when I run it in cmd.exe, it tells me echo is off
Do not add extra space before the equal sign in the set command.
#echo off
set message=Hello World
echo %message%
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
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
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.
Improve this question
I am driving myself crasy trying to read this txt file in a batch file:
Binary CapabilityDescriptions Caption Availability
TRUE Intel(R) Active Management Technology - SOL (COM3) 2
TRUE Intel(R) Active Management Technology - SOL (COM4) 2
TRUE Intel(R) Active Management Technology - SOL (COM5) 2
I am trying to get the the COM number if the Caption contains the string "Intel".
Try this:
#echo off
setlocal
for /f "tokens=4 delims=()" %%a in ('findstr "Intel(R)" findintel.txt') do echo %%a
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a problem with understanding a batch file that is a part of a task (sort of hackme).
I find it hard to find informations about it in google, i dont know, i feel like there isnt any good batch language documentation or soemthing other that is solid.
my first question, what it does? It is possible to dont satisfy the condition ?
if not "!"=="" (
echo Authorization failed!
pause>nul
exit
)
Secound question, what this kind of IF's does ?:
set %1.pass=%2
if "!%1.pass:~5,1!"=="" (
.....
if not "!%1.pass:~6,1!"=="" (
Thank you,
#EDIT
technet.microsoft.com/en-us/library/cc754340(v=ws.10).aspx
i have read it, it doesnt answer my questions
You might check it out by yourself:
#echo off &SETLOCAL
if not "!"=="" (ECHO NOT equal) ELSE ECHO equal
SETLOCAL ENABLEDELAYEDEXPANSION
if not "!"=="" (ECHO NOT equal) ELSE ECHO equal
SET "property.pass=ABCDE"
ECHO %property.pass:~0,1% %property.pass:~1,1% %property.pass:~2,1% %property.pass:~3,1%
Output is:
NOT equal
equal
A B C D