Search found 1042 matches
- 30 Aug 2022 04:13
- Forum: DOS Batch Forum
- Topic: ECHO. FAILS to give text or blank line - Instead use ECHO/
- Replies: 44
- Views: 211961
Re: ECHO. FAILS to give text or blank line - Instead use ECHO/
Hi CJM, This subject seemed to tail off without resolution, yet using ECHO to reliably display information is such a necessity. In my opinion, there is a champion: echo( It's the most reliable in most of the cases. It fails only with: :case1 call echo( /? :case2 setlocal EnableDelayedExpansion set "...
- 04 Mar 2022 00:43
- Forum: DOS Batch Forum
- Topic: Doing MOD calculations in batch
- Replies: 8
- Views: 39388
Re: Doing MOD calculations in batch
Hi juztsteve, your quote solution is interessting but wrong. It computes the modulo, but the quotes doesn't escape the percent sign, instead the complete parsing is broken in your line and works by coincidence. set /a "mod=%divnd%%%divsr%" Is parsed into: 1. set "/a=<the dividend number> %%divsr%" #...
- 20 Dec 2021 15:04
- Forum: DOS Batch Forum
- Topic: Why substring "on" or "off" not echo?
- Replies: 2
- Views: 2494
Re: Why substring "on" or "off" not echo?
Hi goodywp, the echo command uses some special key words, like on, off, /? or <nothing> for special behaviour. echo on - Enable the echo off each command before it will be executed (a debug output) echo off - Disable the echo off commands echo - Show the state of ON or OFF echo /? - Show the help To...
- 10 Dec 2021 13:30
- Forum: DOS Batch Forum
- Topic: Finding /? in arguments
- Replies: 7
- Views: 4837
Re: Finding /? in arguments
Hi Szecska, you can use echo( (echo(%*|findstr /r "\/?")&&goto help Looks odd and you could think, there is a missing closing parenthesis, but it's not. echo( is the only construct, that seems to work in any situation and can output any string without interpreting it. Take a look at ECHO. FAILS to g...
- 23 Nov 2021 01:21
- Forum: DOS Batch Forum
- Topic: How to pipe the outcome of an if-statement to another command?
- Replies: 4
- Views: 4010
Re: How to pipe the outcome of an if-statement to another command?
Hi Reino, when using a pipe, both sides are executed in a subshell. For doing this, the commands are rewritten and executed with cmd.exe, but "IF" statements frequently fails to be rewritten correctly. Debug syntax errors in subshell code Why does delayed expansion fail when inside a piped block of ...
- 19 Nov 2021 02:12
- Forum: DOS Batch Forum
- Topic: Limiting echo & Output word "on"
- Replies: 6
- Views: 4462
Re: Limiting echo & Output word "on"
For reference you could read ECHO. FAILS to give text or blank line - Instead use ...
- 19 Nov 2021 02:07
- Forum: DOS Batch Forum
- Topic: Output text without linefeed, even with leading space or =
- Replies: 18
- Views: 35317
Re: Output text without linefeed, even with leading space or =
Hi atfon,
escape sequences can be outputted with the `set /p` technique.
escape sequences can be outputted with the `set /p` technique.
Code: Select all
"%comspec%" /d /k <nul & <nul set /p ".=%ESC%]0;Main Menu%BEL%"
- 22 Oct 2021 08:00
- Forum: DOS Batch Forum
- Topic: Detect echo state without temporary file
- Replies: 14
- Views: 16596
Re: Detect echo state without temporary file
I reread the code from :getkey, and I simply missed to copy the /u switch
Code: Select all
replace.exe ? . /u /w
- 22 Oct 2021 07:55
- Forum: DOS Batch Forum
- Topic: Detect echo state without temporary file
- Replies: 14
- Views: 16596
Re: Detect echo state without temporary file
I'm astonished about this bug, because I just copied that line from Dave's :getkey.
That nobody found this before, but I can reproduce it.
I played a bit and found another workaround
Looks odd, but seems to work, I can't create a file which is fetched by the "?<" expression.
That nobody found this before, but I can reproduce it.
I played a bit and found another workaround
Code: Select all
replace /w "?<" .
- 17 Oct 2021 10:57
- Forum: DOS Batch Forum
- Topic: Detect echo state without temporary file
- Replies: 14
- Views: 16596
Re: Detect echo state without temporary file
I thought again about this topic, after getting a comment from Jean-François Larvoire on Was ECHO ON or OFF when my Windows .bat was CALLed? . I posted at stackoverflow a new technique to detect it without the need of a temporary file and without any visual effects, but the cursor moves a little bit...
- 11 Jul 2021 03:26
- Forum: DOS Batch Forum
- Topic: Output text without linefeed, even with leading space or =
- Replies: 18
- Views: 35317
Re: Output text without linefeed, even with leading space or =
I started this thread, now I will finish it with a really simple method, shown by sst at How do I add a space on this line?
It's so horrifying simple, I can't understand why nobody found that before.
jeb
Code: Select all
@echo off
setlocal
set "prompt= Hello"
cmd /d /k < nul
echo World
endlocal
jeb
- 08 Jul 2021 01:48
- Forum: DOS Batch Forum
- Topic: Execute UNC path containing literal %, in command line mode
- Replies: 15
- Views: 9659
Re: Execute UNC path containing literal %, in command line mode
Hi noah,
you are right, I missed the SetEnvironmentVariable("my_percent", "%") part.
It works, but I still prefer a single batch line only solution.
I don't like the %=exitcode:~,0%, as it depends on a system variable, but I didn't find a better solution.
jeb
you are right, I missed the SetEnvironmentVariable("my_percent", "%") part.
It works, but I still prefer a single batch line only solution.
I don't like the %=exitcode:~,0%, as it depends on a system variable, but I didn't find a better solution.
jeb
- 06 Jul 2021 09:32
- Forum: DOS Batch Forum
- Topic: Execute UNC path containing literal %, in command line mode
- Replies: 15
- Views: 9659
Re: Execute UNC path containing literal %, in command line mode
Inject the percent signs via an environment variable: Code: Select all char cmd_line[1024] = " /c \"set \"my_percent=\" & \"\\\\localhost\\C$\\Users\\%username%\\Desktop\\%my_percent%path%my_percent%foo bar.bat\"\""; SetEnvironmentVariable("my_percent", "%") (For the rest of the program, refer to v...
- 05 Jul 2021 00:24
- Forum: DOS Batch Forum
- Topic: Execute UNC path containing literal %, in command line mode
- Replies: 15
- Views: 9659
Re: Execute UNC path containing literal %, in command line mode
Hi, yes it works without delayed expansion cmd.exe /c "for %# in (%) DO "\\localhost\C$\Users\%username%\Desktop\%#path%#foo bar.bat"" It's not bullet proof, but it should work in the most cases. It could fail, if a variables exist like set "# in (=FAIL" or set ") DO "\\localhost\C$\Users\=FAIL TOO"...
- 23 Jun 2021 12:08
- Forum: DOS Batch Forum
- Topic: Some undocumented things with turned off command extensions
- Replies: 14
- Views: 13490
Re: Some undocumented things with turned off command extensions
Hi CJM, I cannot get GOTO :EOF (nor GOTO:EOF, with or without space, in all-caps) to function with DisableExtensions unless an :EOF (or :eof) label is present. It's the expected behavior. With Disabled Extensions there is no implicit :EOF label anymore. I'm not sure what Sponge Belly said with, if h...