You are not logged in.
Pages: 1
Hello, I am new here and I have a question.
I made a batch program, but there is a problem.
@echo off
color 0a
title test
:loop
cls
for %%a in (
""
" Batch test."
" Type your name."
) do echo;%%~a
set /p name="your name is:" || goto :loop
cls
for %%a in (
""
" Your name is %name%."
" Is it true?" >>(Problem in this line)<<
" Y. yes"
" N. no"
) do echo;%%~a
choice /c yn /n
if %errorlevel% == 1 exit
if %errorlevel% == 2 goto :loop
In the line "Is it true?" there is a problem. When the batch is executed,
that line not printed on the screen.
Please help!
(Also, sorry if my english is bad )
Offline
You cannot use " ? " when you iterate strings. The plain FOR is intendended for file iteration and ? and * act as wildcards and cannot be escaped
Offline
Oh, thanks!
Offline
How to make batch automatically find any files has .txt format and print the files names in screen?
Offline
In the simplest form:
dir /b/s *.txt
cmd | *sh | ruby | chef
Offline
Thanks. You reply so fast.
Offline
Another question, how to include a file inside batch? The example file is a .png picture.
When the batch is executed, it will extract the file.
Offline
You encode the image to a text representation by one of a number of methods.
The best method depends on the Windows version, 32 bit or 64 bit, and if you want to use third party tools.
Last edited by foxidrive (15 Jul 2014 11:20)
Offline
Thanks for reply. I have my own way to do this now, use CertUtil command.
Offline
Is there someone here who knows VBScript and batch script? If there is, can you convert these scripts?
Script 1:
Sub Decode(InFile As String, OutFile As String)
Dim Cypher As Byte
Dim CypherPos As Long
Dim I As Long
Dim L As Long
Dim File() As Byte
Open InFile For Binary Access Read As #1
L = LOF(1)
ReDim File(L - 1)
Get #1, , File
Close #1
CypherPos = (L And &HFFFFFFE) \ 2
Cypher = File(CypherPos)
For I = 0 To L - 1
File(I) = (256 + File(I) - Cypher) And 255
Next
File(CypherPos) = Cypher
Open OutFile For Output As #2
Close #2
Open OutFile For Binary Access Write As #2
Put #2, , File
Close #2
End Sub
Script 2:
Sub Encode(InFile As String, OutFile As String)
Dim Cypher As Byte
Dim CypherPos As Long
Dim I As Long
Dim L As Long
Dim File() As Byte
Open InFile For Binary Access Read As #1
L = LOF(1)
ReDim File(L - 1)
Get #1, , File
Close #1
CypherPos = (L And &HFFFFFFE) \ 2
Cypher = File(CypherPos)
For I = 0 To L - 1
File(I) = (256 + File(I) + Cypher) And 255
Next
File(CypherPos) = Cypher
Open OutFile For Output As #2
Close #2
Open OutFile For Binary Access Write As #2
Put #2, , File
Close #2
End Sub
Thank you.
Someone? Anyone?
Nevermind.
Last edited by apis (27 Jul 2014 03:35)
Offline
How to get enter, up, down, left, and right button as input for choice command?
Offline
Can someone tell me whats wrong on this script?
@echo off
cls
set "n=0"
set "r=%random%.bat"
:1
echo @echo off > %r%
call :create "A question here" "Answer 1" "Answer 2" "Answer 3" "Answer 4"
call :create "Another question here" "Answer 1" "Answer 2" "Answer 3" "Answer 4"
exit
:create
set /a "n+=1"
set /a "q=%n%+1"
for %%` in (
":data%n%"
"cls"
"echo."
"echo Question #%n%:"
"echo %~1"
"echo a. %~2"
"echo b. %~3"
"echo c. %~4"
"echo d. %~5"
"set /p ans="" | goto :data%n%"
"if "%%ans%%" == "a" goto data%q%"
"if "%%ans%%" == "b" goto data%q%"
"if "%%ans%%" == "c" goto data%q%"
"if "%%ans%%" == "d" goto data%q%"
"goto :data%n%"
) do (echo %%~`>>%r%)
If that script is executed, it will make another .bat file with random number.
@echo off
:data1
cls
echo.
echo Question #1:
echo A question here
echo a. Answer 1
echo b. Answer 2
echo c. Answer 3
echo d. Answer 4
set /p ans="" | goto :data1
if "%ans%" == "a" goto data2
if "%ans%" == "b" goto data2
if "%ans%" == "c" goto data2
if "%ans%" == "d" goto data2
goto :data1
:data2
cls
echo.
echo Question #2:
echo Another question here
echo a. Answer 1
echo b. Answer 2
echo c. Answer 3
echo d. Answer 4
set /p ans="" | goto :data2
if "%ans%" == "a" goto data3
if "%ans%" == "b" goto data3
if "%ans%" == "c" goto data3
if "%ans%" == "d" goto data3
goto :data2
When that random.bat opened, press a or press b or c or d, then press enter, it repeats that question.
Can someone fix this?
Please, someone, reply...
Last edited by apis (18 Aug 2014 01:28)
Offline
You want a double pipe, rather than single, here:
set /p ans="" |
Might not fix it, but won't be helping.
cmd | *sh | ruby | chef
Offline
@apis
You has misspelled set /p ans="" |.
Must be:
set /p ans="" || goto :data1
.::{Honguito98}::.
Offline
Oh.
Offline
There's nothing like an appropriate display of gratitude.
cmd | *sh | ruby | chef
Offline
How to get time/date of a file and save it in a variable?
Offline
for %D in (MyFile.txt) do set "FileDate=%~tD"
.::{Honguito98}::.
Offline
That script doesn't work for me. It's shows me an error.
~tD" was unexpected at this time.
Offline
Sorry for that!
Change %%~tD and for %%D
.::{Honguito98}::.
Offline
Is it possible to have many colours in one screen?
Offline
Offline
How about sounds?
(Sorry if my questions make you tired.)
Offline
Pages: 1