Search found 135 matches

by Eureka!
30 Oct 2020 08:38
Forum: DOS Batch Forum
Topic: Detect when a batch file crashes or closes unexpectedly?
Replies: 6
Views: 9250

Re: Detect when a batch file crashes or closes unexpectedly?

aGerman wrote:
28 Oct 2020 18:59
clicking on the red x,
Right, I missed that one. Thanks for your explanation, Steffen!
by Eureka!
28 Oct 2020 18:25
Forum: DOS Batch Forum
Topic: Detect when a batch file crashes or closes unexpectedly?
Replies: 6
Views: 9250

Re: Detect when a batch file crashes or closes unexpectedly?

I probably missed or misinterpreted some clues here, but shouldn't this be enough? : @echo off setlocal If /i [%1] == [APE] goto :APE ::__________________________________ :: :: WATCHDOG ::__________________________________ :: TITLE Do not close this!! Echo this is the watchdog routine. Don't close t...
by Eureka!
27 Oct 2020 18:37
Forum: DOS Batch Forum
Topic: batch file to spam a removable drive with partitions?
Replies: 2
Views: 2928

Re: batch file to spam a removable drive with partitions?

You forgot to create a VOLUME in your diskpart script :)
by Eureka!
06 Sep 2020 08:12
Forum: DOS Batch Forum
Topic: FOR doesn't iterate properly
Replies: 4
Views: 4545

Re: FOR doesn't iterate properly

Take a look at the explanation of delayed environment variable expansion (command: SET /?) CMD reads FOR ... ( ...) as a single line and all variables will be expanded all at once when reading that entire line. Example: This will only echo the same time multiple times (= the time when the command wa...
by Eureka!
04 Sep 2020 15:39
Forum: DOS Batch Forum
Topic: [How-To] Distinguish between console and terminal (PowerShell hybrid)
Replies: 6
Views: 5308

Re: [How-To] Distinguish between console and terminal (PowerShell hybrid)

The first command: CMD kicks of WMIC.exe so that will be a child process of CMD. The first command searches for that specific WMIC process and reports it's parent-process ID (that is the ProcessID of CMD.exe) The second command: This one reports all child-processes of CMD.exe (and checks if conhost...
by Eureka!
03 Sep 2020 17:21
Forum: DOS Batch Forum
Topic: [How-To] Distinguish between console and terminal (PowerShell hybrid)
Replies: 6
Views: 5308

Re: [How-To] Distinguish between console and terminal (PowerShell hybrid)

I no longer have Terminal installed, so can't test, but checking for child-process conhost.exe of the current CMD.exe should do it? + T:\>wmic process WHERE "CommandLine like 'wmic process WHERE \"CommandLine like%%'" get ParentProcessId /format:list ParentProcessId=2956 + T:\>wmic process WHERE "Pa...
by Eureka!
31 Aug 2020 08:20
Forum: DOS Batch Forum
Topic: g.bat to jump between folders - need help to make it pure batch!
Replies: 16
Views: 14776

Re: g.bat to jump between folders - need help to make it pure batch!

Your description of how g.bat works is basically correct, except the third line with "my" would also be found since somewhere in the database of folders, that "my" folder is also going to be at the end of the line, like "one/more/my". You can also use / or \, so if you were looking to go to "projec...
by Eureka!
30 Aug 2020 10:55
Forum: DOS Batch Forum
Topic: g.bat to jump between folders - need help to make it pure batch!
Replies: 16
Views: 14776

Re: g.bat to jump between folders - need help to make it pure batch!

Just stumbled upon another option, posted on a different forum : WCD
It is modeled after NCD (Norton's Change Directory) with lots of options.

Just reporting; no experience with it (yet)
by Eureka!
05 Aug 2020 12:56
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 22
Views: 13651

Re: Performance Issues with Code

I'm getting between 60 and 80 seconds for a million rows for this, likely because two set statements are being run every single iteration. Thanks for testing (and writing the code, of course)! Lesson learned: Comparing variables is "cheaper" than setting variables. Good to know! [...] Clever!! :thu...
by Eureka!
04 Aug 2020 16:25
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 22
Views: 13651

Re: Performance Issues with Code

In my tests, it saved about 2-3 seconds on a million-line file, so I don't think they'd see any benefits on their side, unfortunately. Thanks, @ShadowThief! Inspired by @Aacini's solution, some pseudo-code as I dont have the time and experience to convert this to proper code: Instead of month n=1.....
by Eureka!
04 Aug 2020 11:54
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 22
Views: 13651

Re: Performance Issues with Code

Purely out of curiousity ... Would replacing this: FOR /F "skip=1 USEBACKQ tokens=1-2 delims=|" %%a IN ("test.txt") DO ( SET "MONTH=!month_val[%%~b]!" with: FOR /F "skip=1 USEBACKQ tokens=2 delims=|" %%a IN ("test.txt") DO ( SET "MONTH=!month_val[%%~a]!" make the code any faster? (it would save on s...
by Eureka!
29 Jul 2020 12:40
Forum: DOS Batch Forum
Topic: Memory leak when reading large text files
Replies: 19
Views: 14303

Re: Memory leak when reading large text files

The only thing done is counting the number of lines containing the string ":\". In that case, you might "get away" with using find /c instead: for /f "usebackq tokens=2 delims=:" %%x in (`find /c /i ":\" "list.txt" `) Do echo COUNT=%%x (the /i is not needed in this case, but was added on auto-pilot...
by Eureka!
22 Jul 2020 14:41
Forum: DOS Batch Forum
Topic: g.bat to jump between folders - need help to make it pure batch!
Replies: 16
Views: 14776

Re: g.bat to jump between folders - need help to make it pure batch!

Thanks, that looks pretty useful! I’ll have a go. If you are also going to use Everything [1], you might be interested that it has an option Replace forward slashes with backslashes . So you can search for - for example - /windows [1] I have yet to encounter someone that doesn't like Everything aft...
by Eureka!
13 Jul 2020 09:15
Forum: DOS Batch Forum
Topic: g.bat to jump between folders - need help to make it pure batch!
Replies: 16
Views: 14776

Re: g.bat to jump between folders - need help to make it pure batch!

Long ago I wrote something similar (batch only) Deleted it as I now use something better (my opinion, of course) as the batch-only version was too slow to my liking. This was the idea behind it (re-created from memory, so I might be off here and there). Mainly to give you some extra ideas: @Echo off...
by Eureka!
13 Jul 2020 03:44
Forum: DOS Batch Forum
Topic: Redirect output to file without using > sign?
Replies: 12
Views: 9456

Re: Redirect output to file without using > sign?

Another approach: @echo off setlocal set OUTPUT=output.txt set line1="<?xml version="1.0" encoding="UTF-8"?>" set line2="<gpx>" set line3="<trk>" set line4="<trkseg>" rem set line5="<trkpt lat="46.361004" lon="-1.180605">" set line6="</trkseg>" set line7="</trk>" set line8="</gpx>" (for /l %%x in (1...