Search found 564 matches
- 23 May 2024 01:45
- Forum: DOS Batch Forum
- Topic: netsh Interface name store as variable
- Replies: 10
- Views: 12255
Re: netsh Interface name store as variable
You can start with this: split this command into separate commands: @NETSH interface show interface name="Wi-Fi" | FIND "Connect state" | FIND "Connected" >nul || GOTO :loop_zfguest @NETSH interface show interface name="Wi-Fi" What does the command above return? And then followed by ((with correct s...
- 21 May 2024 04:47
- Forum: DOS Batch Forum
- Topic: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?
- Replies: 3
- Views: 108
Re: Why does "(title Test) & pause" change the window title to "Test - pause" and not to "Test"?
Do this at the command prompt: title test dir pause set /p "somestr=enter something:" You will see that 'pause' is added to the title or complete 'set /p' command is added to the title. Looks like this is just how 'title' command works - adds a command that stops the processing of the batch file. Ma...
- 20 May 2024 05:05
- Forum: DOS Batch Forum
- Topic: dir ????????.txt does not show only files with length of 8 characters
- Replies: 7
- Views: 320
Re: dir ????????.txt does not show only files with length of 8 characters
I decided to use this solution:
Thanks again for the ideas.
Saso
Code: Select all
dir /b *.txt|(findstr /i /b /r "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].txt")
Saso
- 19 May 2024 03:24
- Forum: DOS Batch Forum
- Topic: dir ????????.txt does not show only files with length of 8 characters
- Replies: 7
- Views: 320
Re: dir ????????.txt does not show only files with length of 8 characters
Thank you both.
Saso
Saso
- 17 May 2024 10:51
- Forum: DOS Batch Forum
- Topic: dir ????????.txt does not show only files with length of 8 characters
- Replies: 7
- Views: 320
Re: dir ????????.txt does not show only files with length of 8 characters
Thanks. But it doesn't work for me. This is what I get. But your idea is good - to check length of the filename.
Code: Select all
c:\
12345678.txt
123456789.txt
87654321.txt
test.txt
c:\
- 17 May 2024 04:22
- Forum: DOS Batch Forum
- Topic: dir ????????.txt does not show only files with length of 8 characters
- Replies: 7
- Views: 320
dir ????????.txt does not show only files with length of 8 characters
How to list only files with filenames of 8-characters in length? @echo off break>12345678.txt break>87654321.txt break>test.txt break>123456789.txt echo dir ????????.txt dir ????????.txt echo -------------- echo dir "????????.>txt" dir "????????.>txt" echo -------------- Output: dir ????????.txt 17....
- 17 May 2024 03:59
- Forum: DOS Batch Forum
- Topic: Difficulty running powershell in a for loop due to unquoting and closing of parenthesis
- Replies: 3
- Views: 328
Re: Difficulty running powershell in a for loop due to unquoting and closing of parenthesis
Wouldn't it be easier for you to use a temporary file and process this temporary file with FOR loop?
Saso
Saso
- 16 May 2024 09:58
- Forum: DOS Batch Forum
- Topic: netsh Interface name store as variable
- Replies: 10
- Views: 12255
Re: netsh Interface name store as variable
Try this: @echo off set "AdapterName=Wi-Fi" :: set currently connected ethernet as variable FOR /f "tokens=3*" %%a IN ('netsh interface show interface ^| findstr /v "VMware" ^| sort /r /+48 ^| findstr "Connected" ^| findstr "Ethernet"') DO (SET "AdapterName=%%b") :: disconnect LAN if connected IF "%...
- 15 May 2024 11:38
- Forum: DOS Batch Forum
- Topic: netsh Interface name store as variable
- Replies: 10
- Views: 12255
Re: netsh Interface name store as variable
As Squashman wrote you don't have a match so variable AdapterName remains undefined. Looks like it does not work if variable AdapterName is not defined at all. Looks like IF fails if variable is not defined. Add set AdapterName=doesnotexist to the beginning of the code. set AdapterName=doesnotexist ...
- 02 May 2024 02:07
- Forum: DOS Batch Forum
- Topic: time sync errorlevel check
- Replies: 5
- Views: 3501
Re: time sync errorlevel check
Try this:
You should treat the 'echo' and 'goto' as one command. You need parentheses ().
Saso
Code: Select all
@echo off
:loop
echo Attempting Time Sync...
w32tm /resync | find /i "The command completed successfully." >nul || (echo Sync Not Working, Retrying...&goto loop)
echo Success!!!!!
pause
exit
Saso
- 25 Apr 2024 03:08
- Forum: DOS Batch Forum
- Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
- Replies: 8
- Views: 2588
Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Very good. Tried and works. But there is a typo:
Missing 'S' at the end:
Saso
Code: Select all
:AppendFileLineToFile-args
Code: Select all
if "[%~4]" NEQ "[]" ( shift & GoTo :AppendFileLineToFile-arg )
- 06 Mar 2024 10:18
- Forum: DOS Batch Forum
- Topic: How to debug this bat file
- Replies: 6
- Views: 3202
Re: How to debug this bat file
So, did you try it? Does it work? Start here: https://ss64.com/nt/syntax-esc.html Escape Character ^ Escape character. Adding the escape character before a command symbol allows it to be treated as ordinary text. These characters which normally have a special meaning can be escaped and then treated ...
- 05 Mar 2024 12:08
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 11374
Re: Macro for Dummies
Thank you all for all the info! I really appreciate it. I will go thru these posts in the following hours/days and post back.
Saso
(as mentioned I've been offline for some time)
Saso
(as mentioned I've been offline for some time)
- 05 Mar 2024 10:48
- Forum: DOS Batch Forum
- Topic: How to debug this bat file
- Replies: 6
- Views: 3202
Re: How to debug this bat file
Been offline for a while.
Maybe you should remove this line
or add ^ infront of the problematic characters (, ), |.
Maybe there are more.
Try this and let us know.
Saso
Maybe you should remove this line
Code: Select all
Rem (if command errors) || (exec this command)
Maybe there are more.
Try this and let us know.
Saso
- 10 Feb 2024 14:13
- Forum: DOS Batch Forum
- Topic: Macro for Dummies
- Replies: 16
- Views: 11374
Re: Macro for Dummies
Thanks a lot T3rry. But I think you should go back some more steps and start with the basics. I tried to understand this batch/macro you posted - too complicated. No luck. We would need something like 'hello world' and then go from there. Something like this: @echo off set helloworld=echo Hello Worl...