Search found 178 matches

by atfon
07 Dec 2021 08:57
Forum: DOS Batch Forum
Topic: Simple Counter Issue
Replies: 10
Views: 5530

Re: Simple Counter Issue

Squashman wrote:
07 Dec 2021 08:33
How about you start counting at zero instead.

Code: Select all

set /a "numApps=0"
Otherwise you already have one app before the code even executes.
Perfect. Thanks.
by atfon
07 Dec 2021 08:08
Forum: DOS Batch Forum
Topic: Simple Counter Issue
Replies: 10
Views: 5530

Simple Counter Issue

I'm attempting what should be a relatively simple task. I'm generating a list of installed 64-bit applications and counting the number in one for /f loop. However, the generated file has an extra carriage return and the count indicates 44 lines instead of the actual number of apps (43). Here is the ...
by atfon
01 Dec 2021 09:13
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

Squashman wrote:
01 Dec 2021 08:47
Change the tokens to tokens=1,*
Perfect. Thank you.
by atfon
01 Dec 2021 07:02
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

Hello Antonio (Aacini). Thanks again for this array technique. It works great and I have been adapting it to other commands, such as WMIC. However, I have run into a snag that I haven't been able to sort out. What if the delimiter you are using is also in the value? I will provide a small example: @...
by atfon
22 Nov 2021 11:39
Forum: DOS Batch Forum
Topic: Terminal Escape Sequences expected behavior?
Replies: 3
Views: 2650

Re: Terminal Escape Sequences expected behavior?

I believe it's intented to always have Administrator in the title if you run it elevated. So, you're suspicion is that the sequence provided here is not supposed to remove the word "Administrator" from an elevated batch script? https://docs.microsoft.com/en-us/windows/console/console-virtual-termin...
by atfon
22 Nov 2021 07:23
Forum: DOS Batch Forum
Topic: Terminal Escape Sequences expected behavior?
Replies: 3
Views: 2650

Terminal Escape Sequences expected behavior?

I've noticed a discrepancy between the behavior of certain terminal escape sequences when another instance of cmd.exe or powershell is invoked. I'll provide a couple brief examples. 1. Let's say you want to stop the cursor from blinking: @echo off setlocal enabledelayedexpansion for /f %%e in ('echo...
by atfon
19 Nov 2021 06:56
Forum: DOS Batch Forum
Topic: Output text without linefeed, even with leading space or =
Replies: 18
Views: 36117

Re: Output text without linefeed, even with leading space or =

jeb wrote:
19 Nov 2021 02:07
Hi atfon,
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%"
Thanks Jeb! I tried a bit with set /p, but didn't think to use the ".= for this. Worked like a charm. :)
by atfon
18 Nov 2021 10:16
Forum: DOS Batch Forum
Topic: Output text without linefeed, even with leading space or =
Replies: 18
Views: 36117

Re: Output text without linefeed, even with leading space or =

I love the "%comspec%" /d /k <nul solution here. However, I have a situation using this technique that I haven't been able to solve. Let's say I have a very simple menu like this: @echo off setlocal enabledelayedexpansion for /f %%g in ('%__APPDIR__%forfiles.exe /p "%~dp0." /m "%~nx0" /c "cmd /c ech...
by atfon
16 Nov 2021 14:47
Forum: DOS Batch Forum
Topic: Restore buffer on exit /b [Closed]
Replies: 2
Views: 2295

Re: Restore buffer on exit /b [Closed]

I tried to use an alternate screen buffer, resize it, and later turn back to the original buffer. https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#alternate-screen-buffer However, updating the size of the alternate buffer doesn't seem to be supported. Steffen Than...
by atfon
16 Nov 2021 13:41
Forum: DOS Batch Forum
Topic: Restore buffer on exit /b [Closed]
Replies: 2
Views: 2295

Restore buffer on exit /b [Closed]

Edit: Please disregard.I had previously turned off the cursor with a terminal escape sequence. The powershell command works fine. I have a script which changes the console screen height and width periodically with the mode con command. I'd like to reset it back to the defaults on exit /b. I can use...
by atfon
05 Nov 2021 11:18
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

I defined elements of netsh array instead of individual variables in order to group them, but you may define the variables as you wish... You may find several one-word variables this way: findstr /BI "IfLuid IFIndex State" You need to use the /C:"one two" form only when you want a two-or-more words...
by atfon
05 Nov 2021 10:12
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

Watch the darn code execute. C:\Users\Squashman\Desktop>afton.bat C:\Users\Squashman\Desktop>for /F "tokens=1,2 delims=: " %g in ('netsh interface ipv4 show interface "Ethernet" | findstr /BIC:"IfLuid " /BIC:"IFIndex " /BIC:"State "') do set "%g=%h" C:\Users\Squashman\Desktop>set "IfLuid=ethernet_3...
by atfon
05 Nov 2021 09:33
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

I literally addressed that in my first comment and code I provided in my first post. Thank you for your assistance, @Squashman. I apologize for being slow about this, but I guess I'm missing something here. In my example, I thought I was asking for token 2 when I used tokens=2? I'm not sure I under...
by atfon
05 Nov 2021 08:50
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

I literally addressed that in my first comment and code I provided in my first post. Thank you for your assistance, @Squashman. I apologize for being slow about this, but I guess I'm missing something here. In my example, I thought I was asking for token 2 when I used tokens=2? I'm not sure I under...
by atfon
05 Nov 2021 08:20
Forum: DOS Batch Forum
Topic: netsh: capture multiple variables in one for loop
Replies: 13
Views: 7051

Re: netsh: capture multiple variables in one for loop

Use the TOKENS to your advantage. You are specifically not asking for TOKEN 1. If you asked for both TOKENS, then all you would need to do for your set command is: set "%%g=%%h" The FINDSTR command can be modified for multiple search parameters a couple of different way. findstr /C:"IfLuid" /C:"IFI...