Search found 89 matches
- 12 Jun 2020 13:52
- Forum: DOS Batch Forum
- Topic: Batch hex edit offset from filename
- Replies: 8
- Views: 7103
Re: Batch hex edit offset from filename
For work I regularly end up with a bunch of hex files with the extension .hex, but I can have anywhere from 5 all the way up to in the hundreds. Most of the time the files will be the same, but require me to open them and edit a select set of values before saving and closing. Right now I am using H...
- 07 Apr 2020 01:45
- Forum: DOS Batch Forum
- Topic: Batch - Browse directory not work
- Replies: 3
- Views: 3794
Re: Batch - Browse directory not work
Your subroutine :treatment is missing the 'end subroutine' command.
This causes processing of :treatment to continue with the command in :end, so processing stops with the''exit %CodeRetour%' command.
Add 'exit/B' or 'goto :eof' at the end of the subroutine to correct this.
This causes processing of :treatment to continue with the command in :end, so processing stops with the''exit %CodeRetour%' command.
Add 'exit/B' or 'goto :eof' at the end of the subroutine to correct this.
- 28 Feb 2020 06:03
- Forum: DOS Batch Forum
- Topic: How to replace extension of a filename stored in variable?
- Replies: 6
- Views: 8517
Re: How to replace extension of a filename stored in variable?
The 'set "file2=%%~i"' does work, but is done inside the for-commandblock enclosed in ()
Use delayed expansion to echo and use the uptodate value of %file2%.
Change %file2% in !file2! and %newfile2% in !newfile2! and your code will work as expected.
Use delayed expansion to echo and use the uptodate value of %file2%.
Change %file2% in !file2! and %newfile2% in !newfile2! and your code will work as expected.
- 07 Dec 2011 15:14
- Forum: DOS Batch Forum
- Topic: Searching Double quote using FINDSTR inside FOR
- Replies: 4
- Views: 6205
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
- 03 Dec 2011 19:12
- Forum: DOS Batch Forum
- Topic: Help me escape special characters used in a %VAR% variable
- Replies: 10
- Views: 8213
Re: Help me escape special characters used in a %VAR% variab
I am not entirely sure but these might work:
The first: leave out the caret
The second: leave out the redirect, find does not need it
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
- 02 Dec 2011 19:12
- Forum: DOS Batch Forum
- Topic: what is wrong with IF else, please help me
- Replies: 7
- Views: 7850
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...
- 02 Dec 2011 10:25
- Forum: DOS Batch Forum
- Topic: what is wrong with IF else, please help me
- Replies: 7
- Views: 7850
Re: what is wrong with IF else, please help me
A minor syntax problem might be the problem.
change EQU to EQL
change EQU to EQL
- 25 Nov 2011 02:39
- Forum: DOS Batch Forum
- Topic: Limit CMD processing to internal commands, safer and faster?
- Replies: 16
- Views: 20095
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...
- 23 Nov 2011 02:46
- Forum: DOS Batch Forum
- Topic: Limit CMD processing to internal commands, safer and faster?
- Replies: 16
- Views: 20095
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...
- 22 Nov 2011 15:16
- Forum: DOS Batch Forum
- Topic: How to check if parameter is file (or directory)?
- Replies: 8
- Views: 12259
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%
- 22 Nov 2011 05:08
- Forum: DOS Batch Forum
- Topic: Limit CMD processing to internal commands, safer and faster?
- Replies: 16
- Views: 20095
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...
- 21 Nov 2011 17:51
- Forum: DOS Batch Forum
- Topic: Limit CMD processing to internal commands, safer and faster?
- Replies: 16
- Views: 20095
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...
- 21 Nov 2011 17:11
- Forum: DOS Batch Forum
- Topic: Limit CMD processing to internal commands, safer and faster?
- Replies: 16
- Views: 20095
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...
- 19 Nov 2011 08:28
- Forum: DOS Batch Forum
- Topic: I'm almost done, but now stucked in duplicate check.
- Replies: 13
- Views: 11208
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...
- 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: 7380
Re: Dos batch to return 1 or 0 exit code after SQL query.
use the exit command
exit /b 0 or exit /b 1
exit /b 0 or exit /b 1