Search found 26 matches

by OJBakker
07 Dec 2011 15:14
Forum: DOS Batch Forum
Topic: Searching Double quote using FINDSTR inside FOR
Replies: 4
Views: 2467

Re: Searching Double quote using FINDSTR inside FOR

or with less carets but more ""

Code: Select all

FOR /f "tokens=1 delims=:" %a in ('"FINDSTR /n /c:"^"" s.txt"') do echo %a
by OJBakker
03 Dec 2011 19:12
Forum: DOS Batch Forum
Topic: Help me escape special characters used in a %VAR% variable
Replies: 10
Views: 2454

Re: Help me escape special characters used in a %VAR% variab

I am not entirely sure but these might work:
SET COMMAND=('find /n "" < %2')
SET COMMAND=('find /n "" %2')


The first: leave out the caret
The second: leave out the redirect, find does not need it
by OJBakker
02 Dec 2011 19:12
Forum: DOS Batch Forum
Topic: what is wrong with IF else, please help me
Replies: 7
Views: 2455

Re: what is wrong with IF else, please help me

? EQU is correct, EQL does nothing. Personally I prefer using == for EQU comparisons. You are right. I got EQL from if /? (Vista language: dutch) EQL - is gelijk aan NEQ - is niet gelijk aan LSS - kleiner dan LEQ - kleiner dan of gelijk aan GTR - groter dan GEQ - groter dan of gelijk aan I always u...
by OJBakker
02 Dec 2011 10:25
Forum: DOS Batch Forum
Topic: what is wrong with IF else, please help me
Replies: 7
Views: 2455

Re: what is wrong with IF else, please help me

A minor syntax problem might be the problem.
change EQU to EQL
by OJBakker
25 Nov 2011 02:39
Forum: DOS Batch Forum
Topic: Limit CMD processing to internal commands, safer and faster?
Replies: 16
Views: 7530

Re: Limit CMD processing to internal commands, safer and fas

These are not the same: set "PathExt=" set "PathExt=;" The first deletes the PathExt from environment. CMD falls back to internal default:.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC The second set PathExt to: No extensions to search for. I have tested some more just to be sure: Disabli...
by OJBakker
23 Nov 2011 02:46
Forum: DOS Batch Forum
Topic: Limit CMD processing to internal commands, safer and faster?
Replies: 16
Views: 7530

Re: Limit CMD processing to internal commands, safer and fas

If I set the path to nothing DOS will not search the path for a file named echo when echo. right ? Almost, just disabling path is not enough. FileSearch will still be done in the current directory. That is why the FileExt has to be disabled as well. I was wondering if it also has effect on performa...
by OJBakker
22 Nov 2011 15:16
Forum: DOS Batch Forum
Topic: How to check if parameter is file (or directory)?
Replies: 8
Views: 3460

Re: How to check if parameter is file (or directory)?

A similar solution using only the file-attributes.

Code: Select all

@echo off&setlocal enableextensions
set attr=%~a1&set otype=?
if defined attr if "%attr:~0,1%" == "d" (set otype=D) else (set otype=F)
echo otype=%otype%
by OJBakker
22 Nov 2011 05:08
Forum: DOS Batch Forum
Topic: Limit CMD processing to internal commands, safer and faster?
Replies: 16
Views: 7530

Re: Limit CMD processing to internal commands, safer and fas

hmmm I guess my explanation was not very clear. I started with Jebs "Call Set" - "Set.bat" vulnerability. Tried to encapsulate the Call Set to isolate this from de FileSearch. Then I expanded my test to all internal commands. I can confirm that all internal commands are vulnerabl...
by OJBakker
21 Nov 2011 17:51
Forum: DOS Batch Forum
Topic: Limit CMD processing to internal commands, safer and faster?
Replies: 16
Views: 7530

Re: Limit CMD processing to internal commands, safer and fas

Restoring the path is not a requirement, just good practice. Imagine working from the commandline. You run a batchfile that wipes the path and does not restore it before finishing. Suddenly your external commands don't work anymore. Just because these are normally found through the default path-sear...
by OJBakker
21 Nov 2011 17:11
Forum: DOS Batch Forum
Topic: Limit CMD processing to internal commands, safer and faster?
Replies: 16
Views: 7530

Limit CMD processing to internal commands, safer and faster?

In the thread CALL me, or better avoid call at http://www.dostips.com/forum/viewtopic.php?f=3&t=1947&hilit=precedence Jeb demonstrated the slowness and unsafety of 'call set' and 'call echo' The code below is an attempt to tackle both problems. This is done by skipping the superfluous direct...
by OJBakker
19 Nov 2011 08:28
Forum: DOS Batch Forum
Topic: I'm almost done, but now stucked in duplicate check.
Replies: 13
Views: 2854

Re: I'm almost done, but now stucked in duplicate check.

A quick glance at your code Errors for external dos commands are not so weird. With set "path=D:\TEST\%petsa%" you have blocked access to the previous path including access to %windir%\system32 the location of all external dos commands. Change this line to path=%path%;D:\TEST\%petsa% or at...
by OJBakker
18 Nov 2011 03:59
Forum: DOS Batch Forum
Topic: Dos batch to return 1 or 0 exit code after SQL query.
Replies: 5
Views: 3471

Re: Dos batch to return 1 or 0 exit code after SQL query.

use the exit command
exit /b 0 or exit /b 1
by OJBakker
16 Nov 2011 15:38
Forum: DOS Batch Forum
Topic: Reverse Parsing
Replies: 10
Views: 4838

Re: Reverse Parsing

If you enumerate the file with leading zeroes the reverse ordering can be done with Sort /R
by OJBakker
08 Nov 2011 01:24
Forum: DOS Batch Forum
Topic: create a file and save in a specified directory
Replies: 1
Views: 1511

Re: create a file and save in a specified directory

use full path to test.txt

Code: Select all

echo > c:\test\test.txt
by OJBakker
04 Nov 2011 04:21
Forum: DOS Batch Forum
Topic: How to replace "=","*", ":" in a variable
Replies: 33
Views: 32611

Re: How to replace "=","*", ":" in a variable

Oops,
It seems I confused myself :D