Search found 222 matches
- 05 Sep 2017 09:22
- Forum: DOS Batch Forum
- Topic: Variable expansion inside :: comments?
- Replies: 10
- Views: 8315
Re: Variable expansion inside :: comments?
@Dave Thanks for the refresher! @Phil Something like: set "var=%var:#=$$%" could potentially double a variable in size. And if the variable is over 4095 characters to begin with, it will overflow and cause a fatal error. Is there any way to catch such errors and take remedial action? - SB
- 25 Aug 2017 07:56
- Forum: DOS Batch Forum
- Topic: Variable expansion inside :: comments?
- Replies: 10
- Views: 8315
Variable expansion inside :: comments?
Hello All! I was trying to catch errors from overflowing variables (is it possible, btw?) when I noticed the following: @echo off & setlocal enableextensions disabledelayedexpansion :: create variable containing 4k hashes set "hashFile=%tmp%\hashFile.tmp" if not exist "%hashFile%&...
- 06 Apr 2017 13:03
- Forum: DOS Batch Forum
- Topic: Can anyone explain what is happening here
- Replies: 3
- Views: 5040
Re: Can anyone explain what is happening here
Hello All! In 2008, a Stack Overflow user asked how to echo a newline in Batch files. Someone called Ken posted this answer . This prompted a request for an explanation of how the code worked, but Ken was unforthcoming. So Jeb took up the slack and provided this now famous answer … two and a half ye...
- 01 Mar 2017 09:41
- Forum: DOS Batch Forum
- Topic: proof of concept: alternate asynchronous non-blocking input
- Replies: 7
- Views: 8097
Re: proof of concept: alternate asynchronous non-blocking input
Hi Phil,
I didn’t know you could coax a tab from robocopy like that. Thanks for the tip!
- SB
I didn’t know you could coax a tab from robocopy like that. Thanks for the tip!
- SB
- 15 Feb 2017 16:10
- Forum: DOS Batch Forum
- Topic: Multi-line menu with options selection via DOSKEY
- Replies: 15
- Views: 34755
Re: Multi-line menu with options selection via DOSKEY
Hello All! Here’s an alternative approach I cobbled together: @echo off & setlocal enableextensions disabledelayedexpansion (call;) title Menu Demo mode con lines=15 cols=20 (set lf=^ %= DO NOT DELETE =% ) set ^"nl=^^^%lf%%lf%^%lf%%lf%^" set ^"\n=^^^%lf%%lf%^%lf%%lf%^^" cls e...
- 14 Feb 2017 13:11
- Forum: DOS Batch Forum
- Topic: Some undocumented things with turned off command extensions
- Replies: 14
- Views: 13725
Re: Some undocumented things with turned off command extensions
Hi Penpen, Thanks for explaining GOTO’s mysterious behaviour. And you don’t need the body of a FOR loop or an IF block. An unconditional parenthesized block will do. See my previous post for a simplified code example. And you’re right about the ampersand as command separator. I don’t know what I was...
- 12 Feb 2017 15:23
- Forum: DOS Batch Forum
- Topic: Some undocumented things with turned off command extensions
- Replies: 14
- Views: 13725
Re: Some undocumented things with turned off command extensions
Hi Again! I noticed the GOTO glitch when playing around with the code developed in the Foolproof Counting of Arguments topic. I’ve boiled it down to this: @echo off & setlocal enableextensions disabledelayedexpansion ( goto skip :skip echo(first label ) :skip echo(second label endlocal & got...
- 12 Feb 2017 11:18
- Forum: DOS Batch Forum
- Topic: Some undocumented things with turned off command extensions
- Replies: 14
- Views: 13725
Re: Some undocumented things with turned off command extensions
Hello All! Interesting discussion. I’d like to add the following observations made while extensions were disabled. The PROMPT command doesn’t work. Neither does: set "prompt=@" Otoh… set prompt=@ does work. And another thing I’ve noticed is that if there are 2 labels with the same name, GO...
- 06 Jan 2017 12:57
- Forum: DOS Batch Forum
- Topic: Putting a PC to sleep from a batch
- Replies: 27
- Views: 32123
Re: Putting a PC to sleep from a batch
Hi Penpen,
That’s perfect! Thanks again.
- SB
That’s perfect! Thanks again.
- SB
- 05 Jan 2017 17:12
- Forum: DOS Batch Forum
- Topic: Putting a PC to sleep from a batch
- Replies: 27
- Views: 32123
Re: Putting a PC to sleep from a batch
Hi Penpen,
I’d like to make suspend.exe even more polite!
Please tell me the C# code for returning error level 0 if the program ran successfully, and error level 1 if there was a problem.
Thanks!
- SB
I’d like to make suspend.exe even more polite!
Please tell me the C# code for returning error level 0 if the program ran successfully, and error level 1 if there was a problem.
Thanks!
- SB
- 04 Jan 2017 15:10
- Forum: DOS Batch Forum
- Topic: Putting a PC to sleep from a batch
- Replies: 27
- Views: 32123
Re: Putting a PC to sleep from a batch
Hi All! I borrowed Penpen’s C# Hybrid , transplantedd some code I found in this CodeHill article , and ended up with suspend.cmd: // // >nul 2>nul & @goto main /* :main @echo off & setlocal enableextensions disabledelayedexpansion set "csc=" pushd "%SystemRoot%\Microsoft.NET\F...
- 31 Dec 2016 14:25
- Forum: DOS Batch Forum
- Topic: line numbers in find vs findstr
- Replies: 10
- Views: 13048
Re: line numbers in find vs findstr
Hi Again, Null characters are notoriously difficult to deal with, as discussed in Robust Line Counter . If an input text file is contaminated with null characters, the best course of action is to get rid of them. But if that isn’t possible, there are workarounds. For example, the following snippet a...
- 28 Dec 2016 09:24
- Forum: DOS Batch Forum
- Topic: line numbers in find vs findstr
- Replies: 10
- Views: 13048
Re: line numbers in find vs findstr
Hi Spodermon! Happy Christmas and welcome to the forum. Paste the following (untested) code into an empty Notepad window and save the file as lineNo.cmd: @echo off & setlocal enableextensions disabledelayedexpansion for /f "delims=:" %%A in (' findstr /bilnc:"portshow 0" &quo...
- 10 Nov 2016 04:29
- Forum: DOS Batch Forum
- Topic: Resetting multiple variables at once
- Replies: 4
- Views: 5313
- 07 Nov 2016 13:47
- Forum: DOS Batch Forum
- Topic: Foxidrive has left us
- Replies: 42
- Views: 183803
Re: Foxidrive has left us
Hello All, I am shocked and saddened to hear of FoxiDrive’s untimely death. He tirelessly and selflessly devoted his free time to helping others. He leaves behind an enduring legacy in the form of thousands of patient and thoughtful answers to programming questions asked on forums and newsgroups fro...