Search found 4566 matches

by aGerman
30 Oct 2011 05:12
Forum: DOS Batch Forum
Topic: Shed some light on me
Replies: 4
Views: 5048

Re: Shed some light on me

You have to read the output of DIR and the text file at the same time. Jeb shared a new SET /P technique which you can use synchronously with a FOR loop. Untested: @echo off setlocal enabledelayedexpansion REM *** find each subfolder for /d %%i in (*) do ( REM *** change the working directory pushd ...
by aGerman
29 Oct 2011 14:19
Forum: DOS Batch Forum
Topic: admin privileges screwing up mkdir
Replies: 1
Views: 2602

Re: admin privileges screwing up mkdir

That's a well known problem. As soon as you run it as admin the working directory is c:\windows\system32 (I'm virtually certain your folders are created there).
To avoid that you could prepend the following line to your code:

Code: Select all

@cd /d "%~dp0"

Regards
aGerman
by aGerman
28 Oct 2011 15:41
Forum: DOS Batch Forum
Topic: "Unexpected Do"
Replies: 2
Views: 4024

Re: "Unexpected Do"

Try:

Code: Select all

>>"exec-ds.bat" echo for %%%%A in ("DM.txt") do if %%%%~zA equ 0 del "DM.txt"


Regards
aGerman
by aGerman
28 Oct 2011 15:36
Forum: DOS Batch Forum
Topic: SET commands
Replies: 8
Views: 9257

Re: SET commands

You can always CALL another batch file to work with the same environment. bat1.bat @echo off set /a var1=1 echo I'm bat1. echo My current var environment: set var echo I'm going to CALL bat2 echo( call bat2.bat 2 echo This is bat1 again. echo My current var environment: set var echo( pause bat2.bat ...
by aGerman
28 Oct 2011 15:06
Forum: DOS Batch Forum
Topic: Need help with batch file.
Replies: 1
Views: 2392

Re: Need help with batch file.

A password request in a batch file? That doesn't make any sense. However you could count all windows which have the same window title. @echo off &setlocal title limit test set /a n=0 for /f %%i in ('tasklist /fi "imagename eq cmd.exe" /fi "windowtitle eq limit test" /nh^|find...
by aGerman
28 Oct 2011 14:49
Forum: DOS Batch Forum
Topic: Colon Philosophy
Replies: 17
Views: 20955

Re: Colon Philosophy

Well, actually it's very simple. The syntax is GOTO label except of GOTO :EOF. That's what you can find in the documentation. If GOTO :label works then a programmer will call it "undefined behavior". You can't demand functioning.

Regards
aGerman
by aGerman
28 Oct 2011 14:02
Forum: DOS Batch Forum
Topic: SET commands
Replies: 8
Views: 9257

Re: SET commands

OK, but where does it fail? Or didn't you check whether the variables are incorrect?

Code: Select all

@echo off
set str=%~d0%~p0
echo %str%
set str=%str:~2,-6%
echo %str%
set sourcedrv=%~d0%str%source\
echo %sourcedrv%
pause


Regards
aGerman
by aGerman
28 Oct 2011 13:46
Forum: DOS Batch Forum
Topic: Colon Philosophy
Replies: 17
Views: 20955

Re: Colon Philosophy

:eof is no label. It's only a virtual expression which tells the parser to jump to the end of file. For that reason only for goto :eof needs the colon.

Regards
aGerman
by aGerman
28 Oct 2011 11:23
Forum: DOS Batch Forum
Topic: SET commands
Replies: 8
Views: 9257

Re: SET commands

@Rileyh
%~d0 will be expanded to the drive of the currently running batch file while %~p0 is expanded to the path. You could also combine it to %~dp0.

@Podde
Actually I don't understand your problem.

Regards
aGerman
by aGerman
28 Oct 2011 11:14
Forum: DOS Batch Forum
Topic: for /f has a problem
Replies: 2
Views: 3834

Re: for /f has a problem

@ wmaddox3
Sorry, but I can't comprehend the problem. Of course it will fail if the file doesn't exist...

Regards
aGerman
by aGerman
28 Oct 2011 11:03
Forum: DOS Batch Forum
Topic: Running Command Processor from .bat
Replies: 1
Views: 2192

Re: Running Command Processor from .bat

What about the PAUSE command?

Regards
aGerman
by aGerman
28 Oct 2011 11:00
Forum: DOS Batch Forum
Topic: "REM"ing a command in another file
Replies: 4
Views: 4514

Re: "REM"ing a command in another file

I don't understand the reason for that. I guess nobody changes a source code via batch, much less if you want to undo that later Call your batch file with an option as parameter and check in the called batch what parameter came in. bat1.bat @echo off call "bat2.bat" /1 "string A"...
by aGerman
28 Oct 2011 10:42
Forum: DOS Batch Forum
Topic: Batch code missing comparisson
Replies: 2
Views: 3249

Re: Batch code missing comparisson

I strictly recomment the opposite style for echo redirections:

Code: Select all

>>"file.txt" echo 1

Regards
aGerman
by aGerman
28 Oct 2011 10:36
Forum: DOS Batch Forum
Topic: Echoing code to a certain point in a batch file
Replies: 1
Views: 2621

Re: Echoing code to a certain point in a batch file

What is this good for? Just pass the new path as parameter and find it as %1. bat1.bat @echo off echo this is bat1 call "bat2.bat" "C:\Windows" echo this is bat1 again pause bat2.bat @echo off echo this is bat2 echo current directory is "%cd%" if exist "%~1" c...
by aGerman
23 Oct 2011 04:00
Forum: DOS Batch Forum
Topic: "REM"ing a command in another file
Replies: 4
Views: 4514

Re: "REM"ing a command in another file

Rileyh, I read this post before but to be honest I have no clue what you are looking for. You can redirect a REM line to another file like each other line. But if you want to insert a line in the middle of an existing code then you will have to write the file completely new and you will have to know...