Search found 97 matches

by Eureka!
05 Aug 2020 12:56
Forum: DOS Batch Forum
Topic: Performance Issues with Code
Replies: 18
Views: 244

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: 18
Views: 244

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: 18
Views: 244

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: 17
Views: 396

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: 10
Views: 1916

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: 10
Views: 1916

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: 1287

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...
by Eureka!
13 Jul 2020 03:35
Forum: DOS Batch Forum
Topic: Figuring out which computer is being used at two different locations
Replies: 12
Views: 692

Re: Figuring out which computer is being used at two different locations

You can also define an asset tag in the BIOS - for example "Remote" - and check for the existence of that asset tag using a WMI query. Or: right before starting your script, connect some random USB stick to this machine that has volume label "Remote" and check for the existence of that (wmic volume ...
by Eureka!
17 May 2020 04:06
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 21
Views: 2028

Re: Debugging / syntax checksing tools for batch

EDIT:

Never mind; you solved it already ..
by Eureka!
16 May 2020 06:10
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 21
Views: 2028

Re: Debugging / syntax checksing tools for batch

Yanta wrote:
15 May 2020 23:52
Doesn't matter that I put there, it will always be the first non-remark after the label.
So, if you replace this line:

Code: Select all

IF /I NOT "%DoGame:~0,1%"=="Y" Echo %time% Not installing games >>C:\%USERDOMAIN%.PostInstall.Log 2>&1
with:

Code: Select all

echo 123
pause
Your script fails?
by Eureka!
15 May 2020 06:15
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 21
Views: 2028

Re: Debugging / syntax checksing tools for batch

This is what I do: - run script with @echo on - On strategic places add code similar to this: PAUSE Start For-Loop1 The PAUSE command will ignore the "Start For-Loop1" part, but it will be shown on the screen, so you know where you are. And more important: it limts the amount of output at a time, ma...
by Eureka!
11 May 2020 09:17
Forum: DOS Batch Forum
Topic: able to run functions from another script?
Replies: 4
Views: 1019

Re: able to run functions from another script?

And yet another suggestion: MAIN.cmd @echo off setlocal set RESULT= call Maths :SUM 1 2 echo SUM RESULT = %RETURN% set RESULT= call Maths :MULTIPLY 1 2 echo MULTIPLY RESULT = %RETURN% MATHS.cmd @echo off setlocal set ALLPARMS=%* set ROUTINE=%1 call set PassParms=%%ALLPARMS:%ROUTINE%=%% call %ROUTINE...
by Eureka!
09 May 2020 18:39
Forum: DOS Batch Forum
Topic: Powershell comment
Replies: 7
Views: 1442

Re: Powershell comment

"Plan B" (or C?):

Code: Select all


(
echo Get-Service
echo #this is a comment
echo ls
) | powershell -command -

Notes:
- Get-Service without the trailing S
- The & should be inside the scriptblock
- I doubt if scriptblocks are even supported from a CMD prompt.
by Eureka!
02 May 2020 16:53
Forum: DOS Batch Forum
Topic: Reg Query For Loop and Reg Add failure
Replies: 2
Views: 1266

Re: Reg Query For Loop and Reg Add failure

Next time, please put your output and code between code tags (use the </> button ) That out of the way: Try your code with echo REG ADD .. instead of REG ADD ... to see what's going on. The issue is that it is returning the same result 3 times over for each key with "S/N: That will be caused by the ...
by Eureka!
29 Apr 2020 19:04
Forum: DOS Batch Forum
Topic: Can SET be filled by a command?
Replies: 6
Views: 1716

Re: Can SET be filled by a command?

Something like this? (not tetsed)

Code: Select all

setlocal enabledelayedexpansion
for %%x in (%__CD__%*) do set LIST=!LIST! "%%x"

echo LIST = %LIST%