Search found 987 matches

by jeb
11 Jul 2021 03:26
Forum: DOS Batch Forum
Topic: Output text without linefeed, even with leading space or =
Replies: 15
Views: 14514

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?

Code: Select all

@echo off

setlocal
set "prompt=  Hello"
cmd /d /k < nul
echo  World

endlocal
It's so horrifying simple, I can't understand why nobody found that before.

jeb
by jeb
08 Jul 2021 01:48
Forum: DOS Batch Forum
Topic: Execute UNC path containing literal %, in command line mode
Replies: 15
Views: 761

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
by jeb
06 Jul 2021 09:32
Forum: DOS Batch Forum
Topic: Execute UNC path containing literal %, in command line mode
Replies: 15
Views: 761

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...
by jeb
05 Jul 2021 00:24
Forum: DOS Batch Forum
Topic: Execute UNC path containing literal %, in command line mode
Replies: 15
Views: 761

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"...
by jeb
23 Jun 2021 12:08
Forum: DOS Batch Forum
Topic: Some undocumented things with turned off command extensions
Replies: 14
Views: 5871

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...
by jeb
31 May 2021 04:14
Forum: DOS Batch Forum
Topic: Unexpected DOS shell expansion of %~n1 and %~x1
Replies: 4
Views: 715

Re: Unexpected DOS shell expansion of %~n1 and %~x1

Hi,

for me it was unexpected, that wildcards are expanded, if the content is in %1..%9 or even in a FOR meta variable.

Code: Select all

@echo off
echo %%1=%1         - no wildcard expansion
echo %%~1=%~1     - no wildcard expansion
echo %%~n1=%~n1 - wildcard expansion
echo %%~f1=%~f1    - wildcard expansion
by jeb
19 May 2021 00:31
Forum: DOS Batch Forum
Topic: Batch coloring not working after git output
Replies: 2
Views: 712

Re: Batch coloring not working after git output

Hallo Bleifuss,

I just tested it on Win10 and it worked,
but I'm sure I saw a similar post about broken escape sequences after some commands.
But as always I can't find the post anymore.

jeb
by jeb
12 Apr 2021 09:17
Forum: DOS Batch Forum
Topic: MS-DOS 6.22 variable trimming
Replies: 3
Views: 1437

Re: MS-DOS 6.22 variable trimming

After review your original problem, I see it's considerably easier, because the output of your program can be used directly. I assume, the output always begins with "CPU_0" You only need two files (GETCPUID.bat and ADD.BAT) GETCPUID.bat @echo off REM Trampoline function for %%L in (%0) do if "%%L"==...
by jeb
02 Apr 2021 06:23
Forum: DOS Batch Forum
Topic: MS-DOS 6.22 variable trimming
Replies: 3
Views: 1437

Re: MS-DOS 6.22 variable trimming

Hi cajunjon, you could split your problem into smaller problems and use some helper files. The list of your problems You need to assign the program output to a variable Split a string into parts substring works only for strings without spaces or other delimiters A variable can't contain an equal sig...
by jeb
19 Feb 2021 01:46
Forum: DOS Batch Forum
Topic: Apostrophe at beginning of file name
Replies: 6
Views: 2284

Re: Apostrophe at beginning of file name

Hi, the error occurs after the file was read, because the FOR loop tries to read the next file! @echo off echo this is myfile>myfile.txt echo this is myapo> "'myapo.txt" echo this is myapo1> "'myapo1.txt" for /F "usebackq delims=" %%G IN ("'myapo.txt" "myfile.txt" ) do echo #1 %%G for /F "usebackq d...
by jeb
17 Feb 2021 03:30
Forum: DOS Batch Forum
Topic: Problem with variable Drive setup for XP/W98SE
Replies: 17
Views: 4540

Re: Problem with variable Drive setup for XP/W98SE

Hi miskox, echo %cd% tested, it works in XP, but not in w98. That was expected, because XP has nearly the same features and bugs like W10. It could be a good solution to write different code for XP and W98 and detect which part has to be used. Something like @echo off >NUL echo dummy & goto :XP REM ...
by jeb
16 Feb 2021 06:00
Forum: DOS Batch Forum
Topic: Problem with variable Drive setup for XP/W98SE
Replies: 17
Views: 4540

Re: Problem with variable Drive setup for XP/W98SE

You could try this one, it works on win98 (tested) and should work on XP, too @echo off if "%1" == "" goto :main goto %1 :main set drv=unknown %COMSPEC% /c %0 :getdrv > drvtmp.bat call drvtmp.bat echo my drive is: %drv% goto :eof :getdrv prompt set drv=$N echo on %=must be empty=% @echo off :eof
by jeb
11 Feb 2021 05:19
Forum: DOS Batch Forum
Topic: Using VT100 input sequences
Replies: 2
Views: 1519

Re: Using VT100 input sequences

Hi Darvil,

take a look at Attempt to catch arrow keystrokes.
There seems no way to detect the arrow keys with pure batch, but it's possible wit powershell and Aacini built some good helper programs for that.

jeb
by jeb
10 Feb 2021 10:19
Forum: DOS Batch Forum
Topic: Cmd.exe bug with special characters
Replies: 2
Views: 1639

Re: Cmd.exe bug with special characters

Hi,

as JFL already said, the echo %0 is the problem.

If you want to see the content without problems, you could use the REM technique.

Code: Select all

@echo off
echo Test

echo on
REM # %0 #
@echo off

echo Test 2
by jeb
29 Nov 2020 11:32
Forum: DOS Batch Forum
Topic: Is it possible restore overwrited contents like F7-Selection?
Replies: 2
Views: 1640

Re: Is it possible restore overwrited contents like F7-Selection?

But there was a bug Bug in vt101 Alternate Screen Buffer?
- Crashes on company-managed computer with Windows 10.0.16299.1625
- Works fine on another one managed by me, with Windows 10.0.19041.84