Search found 31 matches

by Queue
27 Feb 2013 15:40
Forum: DOS Batch Forum
Topic: Batch scripts queueing loop script
Replies: 21
Views: 18166

Re: Batch scripts queueing loop script

Code: Select all

:queue
for /f %%a in ('tasklist ^|find /c /i "process.exe"') do (
if %%a GEQ 2 (
timeout 60
goto:queue
)
)
Queue
by Queue
27 Feb 2013 15:19
Forum: DOS Batch Forum
Topic: Batch scripts queueing loop script
Replies: 21
Views: 18166

Re: Batch scripts queueing loop script

Yes, but it is simply that an IF statement doesn't use DO, DO is part of a FOR statement. DO on its own isn't anything.

foxidrive, what's the purpose of using two find's? Wouldn't [find /c /i "process.exe"] work? I didn't change that in my posts because I assumed you had a reason.

Queue
by Queue
27 Feb 2013 14:53
Forum: DOS Batch Forum
Topic: Batch scripts queueing loop script
Replies: 21
Views: 18166

Re: Batch scripts queueing loop script

Are you changing "process.exe" to be the name of the process you're checking for? Also, GTR 2 should be GEQ 2 (if you want it to match LSS 2, and you can just use else instead, or omit the goto:continue entirely if :continue is immediately after the for loop). Not that either of those woul...
by Queue
27 Feb 2013 14:40
Forum: DOS Batch Forum
Topic: Batch scripts queueing loop script
Replies: 21
Views: 18166

Re: Batch scripts queueing loop script

If you have timeout available, and you're only going to use this batch file on computers where you know timeout is available, just use timeout instead of ping. Using ping as a sleep/wait command is a compatibility hack mainly for XP.

Queue
by Queue
27 Feb 2013 14:02
Forum: DOS Batch Forum
Topic: Batch scripts queueing loop script
Replies: 21
Views: 18166

Re: Batch scripts queueing loop script

The ping adds a delay between loops. It's not actually pinging anything meaningful, just your own computer (localhost) 60 times. You really don't want tasklist (and then 2 finds, and the supporting cmd.exe instances to support the piping) pounding away in batch in a constant loop without some sort o...
by Queue
25 Feb 2013 19:16
Forum: DOS Batch Forum
Topic: The curious case of the defined, empty, 8192+ long variable
Replies: 1
Views: 2903

Re: The curious case of the defined, empty, 8192+ long varia

Also in line with this, as per http://www.dostips.com/forum/viewtopic.php?f=3&t=4312 if you use a cmdcmdline substring / string replacement to ''empty'' the cmdcmdline env var, it will still count as ''defined'' even if it is an empty string. rem [%cmdcmdline:~0,0%] echo [%cmdcmdline%] if define...
by Queue
20 Feb 2013 21:08
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 31
Views: 134842

Re: strLen boosted

Wow, if I point one of the temp file variants at my RAM drive, it is hilariously fast; I don't think any of the in-batch processing variants can beat that. Very good point though: when we can expect delayedexpansion to be enabled, a function that works on the string directly, non-destructively, gets...
by Queue
20 Feb 2013 03:19
Forum: DOS Batch Forum
Topic: strLen boosted
Replies: 31
Views: 134842

Re: strLen boosted

After searching for strlen threads, this one seems the most appropriate place to put this. Building on all previous work in this thread (so very little here is my work), here's my take on strlen: :strlen ( setlocal enabledelayedexpansion & set /a "}=0" if defined %~1 ( for %%# in (4096...
by Queue
19 Feb 2013 10:41
Forum: DOS Batch Forum
Topic: Destructive env var substring
Replies: 18
Views: 26602

Re: Destructive env var substring

%cmdcmdline% often contains quotation marks, so you'd need to handle them first (such as with :: %cmdcmdline:"=*% ), but otherwise, yes, if "%cmdcmdline:~0,-1%" neq "" goto :loop will zero-fill the GetCommandLineW memory location, but I don't think it's affecting GetCommand...
by Queue
19 Feb 2013 03:39
Forum: DOS Batch Forum
Topic: Destructive env var substring
Replies: 18
Views: 26602

Re: Destructive env var substring

Just some fun stuff before I hit the hay: @echo off echo %cmdcmdline% echo; echo;|echo %%cmdcmdline%% echo; set cmdcmdline=%cmdcmdline% echo %cmdcmdline:~1,5% set cmdcmdline= echo %cmdcmdline% echo; :: %cmdcmdline:.=,% echo %cmdcmdline:"=%&echo %cmdcmdline:~1,5%&call(%cmdcmdline:* =!%&a...
by Queue
18 Feb 2013 16:15
Forum: DOS Batch Forum
Topic: Destructive env var substring
Replies: 18
Views: 26602

Re: Destructive env var substring

Good idea :idea: , that explains why some of my tests fails. C:\temp>echo %cmdcmdline:*C=X-123456789012345678901234567890% X-123456789012345678901234567890md C:\temp>cmd #### Here a message box pops up with "cmd.exe application error" ... (translated from german) ##### C:\temp> jeb I coul...
by Queue
18 Feb 2013 04:36
Forum: DOS Batch Forum
Topic: Destructive env var substring
Replies: 18
Views: 26602

Destructive env var substring

@echo off echo %%cmdcmdline%%=%cmdcmdline% echo %%cmdcmdline:~0,6%%=%cmdcmdline:~0,6% echo %%cmdcmdline%%=%cmdcmdline% echo; echo %%temp%%=%temp% echo %%temp:~0,6%%=%temp:~0,6% echo %%temp%%=%temp% echo; echo %%cd%%=%cd% echo %%cd:~0,6%%=%cd:~0,6% echo %%cd%%=%cd% echo; pause cls outputs: %cmdcmdli...
by Queue
17 Feb 2013 23:47
Forum: DOS Batch Forum
Topic: IF THEN syntactic sugar
Replies: 4
Views: 11509

Re: IF THEN syntactic sugar

Using call for the errorlevel was a happy accident. When I originally set out to do this, my ideal result had been a stand-alone %or% , so I was trying all sorts of terrible things to break the parser (if only ascii 0x1A could also work its magic via environment variable!). At one point, I was tryin...
by Queue
16 Feb 2013 17:34
Forum: DOS Batch Forum
Topic: IF THEN syntactic sugar
Replies: 4
Views: 11509

IF THEN syntactic sugar

A quick preface: I enjoy batch's ubiquity, and so while I mostly work with 32-bit x86 assembly, C++ and the occasional interpreted language, I do a fair bit of goofy small projects with batch. Something that always bugged me was how strict batch's IF statement parenthesis were. Namely, I prefer the ...
by Queue
16 Feb 2013 16:40
Forum: DOS Batch Forum
Topic: Why does piping cause delayed expansion?
Replies: 4
Views: 4891

Re: Why does piping cause delayed expansion?

Ah ha! Thanks. I hadn't quite put 2 and 2 together; particularly, I hadn't grasped in what way it'd mix both batch and cmd parsing. I've been referencing your guys' work (particularly on stackoverflow) for what feels like years at this point, but only recently realized this was where a good bit of b...